Hello:

I am using prefixes in my QRC resource chain to keep some sense of order in
my many QML files.

For example, to load a given QML file using the loader:

gloader.source = "qrc:/prefix/realdir/qmlname.qml"

So I need to put the prefix name first, then any actual subdirectory and
then the qml file name.

But how would one accommodate prefixes inside the QML file itself to handle
components.

http://doc.qt.io/qt-5/qtqml-documents-topic.html

Notice how there is no mention how to compensate for QRC prefix or actual
subdirectory where QML file is located.

It appears like the examples ASSUME the QML file is locatable in the ROOT
dir of the QRC tree.






Below is a typical example for components:

// Button.qml
import QtQuick 2.0
Rectangle <http://doc.qt.io/qt-5/qml-qtquick-rectangle.html> {
    width: 100; height: 100
    color: "red"

    MouseArea <http://doc.qt.io/qt-5/qml-qtquick-mousearea.html> {
        anchors.fill: parent
        onClicked: console.log("Button clicked!")
    }
}

The Button type can then be used in an application:

// application.qml
import QtQuick 2.0
Column <http://doc.qt.io/qt-5/qml-qtquick-column.html> {
    Button { width: 50; height: 50 }
    Button { x: 50; width: 100; height: 50; color: "blue" }
    Button { width: 50; height: 50; radius: 8 }
}


But what happens when button.qml is located inside the QRC file at:

/PREFIX/SUBDIR/FILENAME

Do we then change our locations in the:

import QtQuick 2.0
Column <http://doc.qt.io/qt-5/qml-qtquick-column.html> {
    Prefix/SubDir/Button { width: 50; height: 50 }
    Prefix/SubDir/Button { x: 50; width: 100; height: 50; color: "blue" }
    Prefix/SubDir/Button { width: 50; height: 50; radius: 8 }
}


Anybody have some clues, insights, or suggestions?
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to