Results 1 to 3 of 3

Thread: QML Extension plugin as static library

  1. #1
    Join Date
    Jan 2008
    Posts
    20
    Thanks
    1

    Default QML Extension plugin as static library

    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
    Qt Code:
    1. #import 'qrc:/.'
    2.  
    3. SharedWindow
    4. {
    5. }
    6. ...
    To copy to clipboard, switch view to plain text mode 

    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
    Qt Code:
    1. qmlRegisterType<SharedComponent>(uri, 1, 0, "SharedComponent");
    To copy to clipboard, switch view to plain text mode 

    I've also updated the qmldir file to
    Qt Code:
    1. module MyModule
    2. SharedWindow 1.0 SharedWindow.qml
    3. plugin sharedqmllibrary
    To copy to clipboard, switch view to plain text mode 
    but when i try to do in the MyAppMainWindow.qml
    Qt Code:
    1. #import 'qrc:/.'
    2. #import MyModule 1.0
    3.  
    4. SharedComponent
    5. {
    6. }
    7. ...
    To copy to clipboard, switch view to plain text mode 
    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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QML Extension plugin as static library

    Can you clarify if the title or the content of your posting reflects your goal better?
    Do you want a static library or a plugin?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2008
    Posts
    20
    Thanks
    1

    Default Re: QML Extension plugin as static library

    Hmm, I think my brain doesn't work well today. The qmldir stuff is only necessary for a shared library. Just a static library is ok... I can easily make my own init function in it to register all the types and i don't need the qmldir stuff (made it work with a dll to, i just forgot to put the dll on the correct location). Nevermind, problem solved, sorry for the confusion...

Similar Threads

  1. Adding library with .a extension
    By ftl_embedded in forum Qt Programming
    Replies: 9
    Last Post: 4th September 2015, 08:49
  2. Trying to build Qt-SQL-driver-plugin for SQLite-DB with SQLCipher-extension
    By breakthecode in forum Installation and Deployment
    Replies: 1
    Last Post: 26th July 2015, 09:24
  3. How to get shared library extension in .pro
    By Gourmet in forum Qt Tools
    Replies: 0
    Last Post: 27th November 2014, 09:17
  4. Replies: 3
    Last Post: 20th December 2012, 12:48
  5. Extending a plugin in a static library
    By ultim8 in forum Qt Programming
    Replies: 5
    Last Post: 25th March 2010, 15:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.