Answer the question
In order to leave comments, you need to log in
Qml import does not find different directories?
I want to take out a part of qml files for the project.
is:
rootdirectory / myproject / rs /main.qml
rootdirectory / myproject / myproject.pro
rootdirectory / qml / item.qml
how to import in main.qml -> item.qml ?
Did:
import "../../qml" (finds properties in the project, etc. but swears)
import "../../qml/"
import "../../qml/*"
import "qrc: /qml" (registered file alias = "qml/item.qml")
error: no such directory
import "/home/PC/rootdirectory/qml"
import "/home/PC/rootdirectory/qml/"
import "/home/PC /rootdirectory/qml/*"
error:
there are 2 programs and 70% of the total code
Answer the question
In order to leave comments, you need to log in
In general, I was a little inattentive. 1 of the options works (I didn’t have pictures yet and cursed):
in qrc
"<resource="qml">
"<file alias="qml/main.qml">rc/main.qml</file>
"<file alias="qml/item.qml">../../qml/item.qml</file>
In my opinion, qml is not very good at dealing with relative paths that go beyond the root of the project. Try something like this:
Structure:
├── qml
│ └── MyItem.qml
└── project
├── main.cpp
├── main.qml
├── qml.qrc
├── project.pro
import "qml" as Common // Просто "qml"; без "../"
Window {
visible: true
width: 640
height: 480
Common.MyItem {
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question