including qml file from another folder
-
@mzimmers said in including qml file from another folder:
Timepicker
Is DrawerList.qml added to any qmldir inside qmlplugins/Nga/Components?
-
@mzimmers Hi
In your FileA.qml, where you want to use the stuff from DrawerList.qml do the following:
import "../../../../qmlplugins/NgaComponents"
Note I may have miscounted the number ../ in the import, but you get the picture :)
@johngod you didn't miscount, though I think you meant:
import "../../../../qmlplugins/Nga/Components"
But I don't think this is necessary. I already have a line:
import Nga.Components
It may be noteworthy that if I directly reference DrawerList from the same file, that works. It's the argument to the push() that seems to need some pathname, though I'd like to avoid having to do this.
-
@johngod you didn't miscount, though I think you meant:
import "../../../../qmlplugins/Nga/Components"
But I don't think this is necessary. I already have a line:
import Nga.Components
It may be noteworthy that if I directly reference DrawerList from the same file, that works. It's the argument to the push() that seems to need some pathname, though I'd like to avoid having to do this.
@mzimmers Are you using a resource file to store your qml files ? I usually do that, then in the in project editor, I expand the resource file, select the qml file I want to use, right click on the file, there is one option to Copy the Path, something like ":/someFolder/SomeFile.qml" and other that is Copy Url, something like "qrc:/someFolder/SomeFile.qml". One of this options should work, dont remember right now which is the correct. Edit: this are relative paths to the qml files inside the resource files, this is a good approach imho, I fail to see why you would not want to use this relative paths.
-
@mzimmers Are you using a resource file to store your qml files ? I usually do that, then in the in project editor, I expand the resource file, select the qml file I want to use, right click on the file, there is one option to Copy the Path, something like ":/someFolder/SomeFile.qml" and other that is Copy Url, something like "qrc:/someFolder/SomeFile.qml". One of this options should work, dont remember right now which is the correct. Edit: this are relative paths to the qml files inside the resource files, this is a good approach imho, I fail to see why you would not want to use this relative paths.
@johngod said in including qml file from another folder:
Are you using a resource file to store your qml files ?
No, I'm not -- that hasn't been necessary so far. If I decide to do this, would it be best to create it at the top project level, so that it covers all the files referenced in the contained CMake files, or should I create it at the /qml/Components level? Or, does it matter?
-
@johngod said in including qml file from another folder:
Are you using a resource file to store your qml files ?
No, I'm not -- that hasn't been necessary so far. If I decide to do this, would it be best to create it at the top project level, so that it covers all the files referenced in the contained CMake files, or should I create it at the /qml/Components level? Or, does it matter?
@mzimmers You have to use it at top level, since you cannot add files at a upper level folder, then you can add all the qml files of your projet. Using a resource file for your qml files will make them a part of the excutable file, you will not have to worry about deploy them.
-
@mzimmers You have to use it at top level, since you cannot add files at a upper level folder, then you can add all the qml files of your projet. Using a resource file for your qml files will make them a part of the excutable file, you will not have to worry about deploy them.
-
@johngod thanks for the reply. I'm still not sure I understand where I should put my resources file. My project structure looks like this:
If I put the file under qmlplugins, it won't be visible to appNgaIcdFw, will it?@mzimmers I guess it may be better to put shared qml files into a dir like for example: common or general or shared for both project and plugin. I think you may have some base qml files as well for both projects and they may belong to this dir too.
In this way, both projects will use the exactly same path in their own cmake files. -
@mzimmers I guess it may be better to put shared qml files into a dir like for example: common or general or shared for both project and plugin. I think you may have some base qml files as well for both projects and they may belong to this dir too.
In this way, both projects will use the exactly same path in their own cmake files.@JoeCFD My top-level CMakeLists.txt file already has these entries:
add_subdirectory(qmlplugins) add_subdirectory(appNgaIcdFw)
So I think the qmlplugins directory is already doing what you suggested. I think @johngod is correct about me needing a resources file, but I don't know where to place it for it to be visible to everything.
-
@JoeCFD My top-level CMakeLists.txt file already has these entries:
add_subdirectory(qmlplugins) add_subdirectory(appNgaIcdFw)
So I think the qmlplugins directory is already doing what you suggested. I think @johngod is correct about me needing a resources file, but I don't know where to place it for it to be visible to everything.
@mzimmers Hi
I usually would put my resource in the top level directory ngalcdFwProj, but I think you can also put it in qmlplugins and it still would be visible appNgaIcdFw, give it a try. Note that is this last case, you will only be able to add qml files from the qmlplugins and the sub folders to the resource. Note also that you can add several resource files, for example, one for the qmlplugins folder, other for appNgalcdFw, and so on.