Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED]Deploying a Qt Quick 2 plugin with a static build
QtWS25 Last Chance

[SOLVED]Deploying a Qt Quick 2 plugin with a static build

Scheduled Pinned Locked Moved QML and Qt Quick
extension plugiqt.confqmldirdeploymentstatic build
6 Posts 2 Posters 5.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Monomix
    wrote on 31 Jul 2015, 12:54 last edited by Monomix 8 Mar 2015, 13:50
    #1

    We have a Qt Quick 2 plugin used by our Windows application for file system access directly in QML; it's a standard and simple plugin made using the Qt Quick 2 Extension template. When running using the standard Qt build of our application, it works fine, but when making a static build for deployment, it doesn't load - debug output is:

        qrc:///elements/BinaryFile.qml: Type FileAccess unavailable
        qrc:///FileAccess.qml:5:1: module "com.monomix.qmlcomponents" plugin "FileIO"
        not found
    

    The contents of FileAccess.qml are:

       pragma Singleton
    
     import QtQuick 2.3
     import com.monomix.qmlcomponents 1.0
    
    QtObject {
         property FileIO fileIO: FileIO {  id: fileIoInstance }
    }
    

    and the FileIO.dll plugin itself is stored in com/monomix/qmlcomponents, along with the required plugins.qmltypes and qmldir file, which contains:

    module com.monomix.qmlcomponents
    plugin FileIO
    

    At runtime the application recognises the module, so it wouldn't seem to be an issue with paths, but for some reason the plugin isn't found. Any ideas?

    1 Reply Last reply
    1
    • M Offline
      M Offline
      Monomix
      wrote on 3 Aug 2015, 13:48 last edited by Monomix 8 Mar 2015, 13:49
      #2

      After a lot of digging and experimentation, I finally got this working; as usual, the devil is in the (largely undocumented) details. There are still some open questions as to why it works, but it works. Things to note:

      1. The QML extension plugin must be built using the same compiler and static-linked Qt that you're compiling your application with

      2. In the .pro file for you plugin, you need to define QMAKE_MOC_OPTIONS:

           uri = com.yourcompany.qmlcomponents
           QMAKE_MOC_OPTIONS += -Muri=com.yourcompany.qmlcomponents
        
      3. If you're definining a plugin which contains a singleton class, use qmlRegisterSingletonType in your MyPlugin::registerTypes() function rather than qmlRegisterType

      4. For linking your application statically, you need to define classname in your plugin's qmldir file. See http://doc.qt.io/qt-5/qtqml-modules-qmldir.html

      5. When building your application, you should add your custom plugin to QmlImports.qml (see https://forum.qt.io/topic/53072/qml-with-static-build/2)

      6. As with the QtQuick DLLS described in the link in 5., you need to distribute the dynamically-linked build of your plugin with the application, located in a defined plugin path.

      Source code for the plugin project can be found here, for anyone who's interested: https://gist.github.com/anonymous/97d6b1fa78b13439ed35

      1 Reply Last reply
      2
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 9 Sept 2015, 20:23 last edited by
        #3

        Hi,

        You could contribute an update to Qt's documentation with these information or open a bug report (if none already exists) on the bug report system to improve the documentation in that regard

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply 10 Sept 2015, 09:42
        0
        • S SGaist
          9 Sept 2015, 20:23

          Hi,

          You could contribute an update to Qt's documentation with these information or open a bug report (if none already exists) on the bug report system to improve the documentation in that regard

          M Offline
          M Offline
          Monomix
          wrote on 10 Sept 2015, 09:42 last edited by Monomix 9 Oct 2015, 09:42
          #4

          @SGaist I'd gladly do that - how would I go about contributing to the documentation?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 10 Sept 2015, 09:49 last edited by
            #5

            The same you would do for code. You can start by reading the Gerrit Introduction

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Monomix
              wrote on 10 Sept 2015, 09:52 last edited by
              #6

              On it. Merci!

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved