3

I am working on project that will hold shared qml components such as a button, status bar, numeric key pad, etc. I want to be able to compile these qml files into one binary (.so/.dll) to provide for use for multiple applications. currently this is my folder structure for the shared application which is setup as a lib SharedProject (folder structure) - .pro file - sharedassets.qrc - sharedcontrols.qrc - sharedassests (folder) -.qml -.png - qmldir.txt - sharedcontrols (folder) - *.qml -qmldir.txt In my test application I am trying to get these controls to show up through a compile library or rcc file but I am unable to I have tried the following

  • QResoure::registerResoure() in the main.cpp of the test application
  • QML_IMPORT_PATH += dir of the SharedProject
  • QML2_IMPORT_PATH += dir of the SharedProject

(The above works but still requires me to have the qml files within some folder. I need them to be binary and then be able to utilize them in qt creator)

any help on how to properly put my qml into a complied library would be helpful. I have read the Qt modules tutorial but still feel lost on how to accomplish this. If anyone has an example that I can reference would be vary helpful.

  • 1
    I would do a dll that contains set of qml files and some proxy function (for example `getFile(name)`) that will return a file. Another solution is compiled resource, rcc. See my answer to the same question [here](https://stackoverflow.com/questions/40968813/how-create-shared-library-in-qt-qml) – folibis Sep 22 '19 at 09:06
  • Yeah I saw this link earlier. my question on the compile as an rcc. How does my application use the qml types within the rcc. not at run time but during development. Can I still import like I normally would? Normally I have to add to the QML_IMPORT_PATH and QML2_IMPORT_PATH the location of where my qmldir is at. but in this case they are in an rcc so do I just import them into my applications qml by just calling import? – pjorourke05 Sep 23 '19 at 13:41
  • you should register the resource file in the application using `QResource::registerResource("/path/to/resource.rcc");` and so you can use the qml files inside it as all other qml files – folibis Sep 23 '19 at 14:43
  • I have tried this solution with no success. Qt Creator does not know what these qml types are – pjorourke05 Sep 24 '19 at 16:28

0 Answers0