I'm programming a c++/qml application. Since I have many qml-files I wanted to make a directory structure. I already implemented the structure in my filesystem like this:
project
|- qml
|- main.qml
|- widgets
|- Button.qml
|- Label.qml
What I now want to do is to use qrc-prefixes to create exactly the same hierarchy:
main.qrc
/
main.qml
/widgets
Button.qml
Label.qml
This is my example qml-file:
import QtQuick 2.2
import "widgets"
Item {
id: window
width: 800
height: 480
Button {
id: button
anchors.centerIn parent
text: "click me"
}
}
The problem I have, is that the compiler does not know the Button!
EDIT:
Error Message: qrc:///qml/main.qml:4 "widgets": no such directory
The QML-interpreter tries to load your directory at the false place ( filesystem instead of qrc-file ). Try
import "qrc:/widgets"
to solve your issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With