What is the difference between qrc:/ and qrc:///
-
When loading main qml the root QML file, one can use
qrc:/
orqrc:///
as the url scheme:engine.load(QUrl(QLatin1String("qrc:/main.qml")));
or
engine.load(QUrl(QLatin1String("qrc:///main.qml")));
Both approaches work but it seems that
qrc:///
is the recommended approach. So what's the difference between the two? -
@nejatafshar said in What is the difference between qrc:/ and qrc:///:
So what's the difference between the two?
The second one is a valid url while the first is not. The first one only works because the QString passed to the QUrl is parsed in tolerant mode: https://doc.qt.io/qt-5/qurl.html#QUrl-2
-
@Christian-Ehrlicher Thanks. The first one is more concise and I regularly use it where ever I want to address a resource item. So which one is recommended? Is there any circumstances that the first one fails?
-
@Christian-Ehrlicher Thanks. The first one is more concise and I regularly use it where ever I want to address a resource item. So which one is recommended? Is there any circumstances that the first one fails?
@nejatafshar said in What is the difference between qrc:/ and qrc:///:
So which one is recommended
the valid one.
@nejatafshar said in What is the difference between qrc:/ and qrc:///:
Is there any circumstances that the first one fails?
yes as @Christian-Ehrlicher said,
most likely it will fail if QUrl::ParsingMode is set to QUrl::StrictMode