JanW
13th July 2016, 14:49
Hi,
I'm trying to organize my code a little bit, but I'm failing put my shared qml files and C++ components in a separate library. I also want to "protect" my qml files by putting them in a resource file (I'm working on windows + Visual Studio + Qt VS addin). My structure is as follows
RootFolder
-Binaries
--MyApp,exe
--SharedQMLLibrary.lib
-Source
--MyApp
---Main.cpp
---MyAppMainWindow.qml
--Libraries
---SharedQMLLibrary
----SharedWindow.qml
----SharedComponent.cpp
----qmldir
----SharedQMLLibraryResource.qrc
In MySharedQMLLibrary i have a resource.qrc file which has qmldir and SharedWindow.qml as a file. In MyApp i have in the Main.cpp file Q_INIT_RESOURCE(SharedQMLLibraryResource); The qmldir file just contains :
SharedWindow 1.0 SharedWindow.qml
In my MyAppMainWindow.qml i can just do
#import 'qrc:/.'
SharedWindow
{
}
...
and it works. Now I'm struggling to make the C++ components available in MyMainWindow.qml.
I've created a SharedQMLLibrary_plugin class which inherits from QQmlExtensionPlugin and in the registerTypes method i've added
qmlRegisterType<SharedComponent>(uri, 1, 0, "SharedComponent");
I've also updated the qmldir file to
module MyModule
SharedWindow 1.0 SharedWindow.qml
plugin sharedqmllibrary
but when i try to do in the MyAppMainWindow.qml
#import 'qrc:/.'
#import MyModule 1.0
SharedComponent
{
}
...
It complains that module "MyModule" plugin "SharedQMLLibrary" not found. Anybody has any advice on how the qmldir file should look like, what i should import in the application qml files and how the output libraries in my binaries folder should be structured?
Thanks,
Jan
I'm trying to organize my code a little bit, but I'm failing put my shared qml files and C++ components in a separate library. I also want to "protect" my qml files by putting them in a resource file (I'm working on windows + Visual Studio + Qt VS addin). My structure is as follows
RootFolder
-Binaries
--MyApp,exe
--SharedQMLLibrary.lib
-Source
--MyApp
---Main.cpp
---MyAppMainWindow.qml
--Libraries
---SharedQMLLibrary
----SharedWindow.qml
----SharedComponent.cpp
----qmldir
----SharedQMLLibraryResource.qrc
In MySharedQMLLibrary i have a resource.qrc file which has qmldir and SharedWindow.qml as a file. In MyApp i have in the Main.cpp file Q_INIT_RESOURCE(SharedQMLLibraryResource); The qmldir file just contains :
SharedWindow 1.0 SharedWindow.qml
In my MyAppMainWindow.qml i can just do
#import 'qrc:/.'
SharedWindow
{
}
...
and it works. Now I'm struggling to make the C++ components available in MyMainWindow.qml.
I've created a SharedQMLLibrary_plugin class which inherits from QQmlExtensionPlugin and in the registerTypes method i've added
qmlRegisterType<SharedComponent>(uri, 1, 0, "SharedComponent");
I've also updated the qmldir file to
module MyModule
SharedWindow 1.0 SharedWindow.qml
plugin sharedqmllibrary
but when i try to do in the MyAppMainWindow.qml
#import 'qrc:/.'
#import MyModule 1.0
SharedComponent
{
}
...
It complains that module "MyModule" plugin "SharedQMLLibrary" not found. Anybody has any advice on how the qmldir file should look like, what i should import in the application qml files and how the output libraries in my binaries folder should be structured?
Thanks,
Jan