SUMMARY A default value helper for a kcfg entry of a "Url" type that has a default value pointing to "qrc:/" Qt resource (which itself is a valid Url) will return a QUrl object initialized improperly with a malformed "file:qrc:/" value. This is due to the fact that the helper uses QUrl::fromUserInput() to parse the provided value, which in turn does not handle the "qrc:/" Urls, and Qt refuses to make it to. Relevant discussion about fromLocalFile() that behaves identically here: https://bugreports.qt.io/browse/QTBUG-44165 The proposed solution is to make the helper detect the qrc:/ substring and initialize QUrl object directly: if (urlString.startsWith(QStringLiteral("qrc:/"))) { return QUrl(urlString)); } else { return QUrl::fromUserInput(urlString) STEPS TO REPRODUCE 1. Add a kcfg entry: <entry name="SomeConfigSwitch" type="Url"> <default>qrc:/someConfigValue</default> </entry> 2. Add "DefaultValueGetters=true" to .kcfgc file 3. auto defaultConfigUrlValue = PluginSettings::defaultSomeConfigSwitchValue().url() OBSERVED RESULT Notice that defaultConfigUrlValue is "file:qrc:/someConfigValue" EXPECTED RESULT defaultConfigUrlValue should be "qrc:/someConfigValue" SOFTWARE/OS VERSIONS Linux: Ubuntu 20.04.1 LTS KDE Frameworks Version: 5.68 Qt Version: 5.12
Actually, I just realized that the "SomeConfigSwitch" (using the same example) is also initialized improperly in the same fashion, so this doesn't apply to default value helpers only.