I have a problem with importing style files from a subdirectory.
This is the concerning section in my *.pro file:
QML_IMPORT_PATH = \
src/gui/qml/views/startview/ \
src/gui/qml/views/createlocalgameview/ \
src/gui/qml/views/ \
src/gui/qml/components/styles/ \
src/gui/qml/components/ \
src/gui/qml/js/
For example i have a file MyTextFieldStyle.qml placed in src/gui/qml/components/styles/:
TextFieldStyle {
[...]
}
and i have a file TextArea.qml placed in src/gui/qml/components/:
Item {
[...]
TextField {
id: textField
style: MyTextFieldStyle {}
}
[...]
}
Now i get this error:
TextArea.qml: MyTextFieldStyle is not a type
If i put the MyTextFieldStyle.qml in the same directory like TextArea.qml (src/gui/qml/components/) it works fine. But i have many components and many styles and so i want to seperate them to have a better overview. Is there any way i can get this working?
It should be enough putting at the top of the file an import statement with relative paths.
In your example, you can use import './styles'.
As stated in the comments, QML_IMPORT_PATH is not meant to solve that problem.
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