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. How to deploy custom plugins QML
Forum Update on Monday, May 27th 2025

How to deploy custom plugins QML

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 998 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.
  • D Offline
    D Offline
    davidino
    wrote on 31 Dec 2018, 11:48 last edited by davidino
    #1

    GoodMorning,
    I'm using a Raspberry pi3 with Qt version 5.11 installed through boot2qt.
    I'm struggling to understand to deploy a custom made plugin. I supposed the plugin has to be deploy both in the target (Rapberry) and in my host PC. I've followed both
    http://doc.qt.io/qt-5/qtqml-modules-cppplugins.html and https://docs.huihoo.com/qt/5.x/qtqml-tutorials-extending-qml-example.html#chapter-6-writing-an-extension-plugin, but they are not clear enough for me.
    Basically I don't know where and how deploy the generated plugin..

    Can you advise?

    Thank you very much.

    Below you can find my .pro file

    QT += qml quick
    CONFIG += c++11
    
    TEMPLATE = lib
    CONFIG += qt plugin
    DESTDIR = imports/PieChart
    TARGET = qmlPieChartPlugin
    
    CONFIG += install_ok  # Do not cargo-cult this!
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Refer to the documentation for the
    # deprecated API to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
            main.cpp \
        piechart.cpp \
        pieslice.cpp \
        chartsplugin.cpp
    
    RESOURCES += qml.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # Default rules for deployment.
    # target.path = /home/root
    # INSTALLS += target
    
    HEADERS += \
        piechart.h \
        pieslice.h \
        chartsplugin.h
    

    The structure of my project is:

    0_1546257299849_Schermata del 2018-12-31 12-50-41.png

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 1 Jan 2019, 16:07 last edited by
      #2

      You can look at my simple example at GIT

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      2
      • D Offline
        D Offline
        davidino
        wrote on 5 Jan 2019, 16:15 last edited by
        #3

        Hello @dheerendra ,
        thank you for your example. Since I'm a newbie with plugins, I didn't understand some things, so I have a couple of questions:

        • Have you got an example that use the plugin as well? In this case, is it necessary to add the plugin path in QML_IMPORT_PATH?

        • I saw that in the target, both the qmldir file and the library .so are installed. Is it mandatory to transfer the qmldir file?
          Besides in DESTDIR only the library is transferred (not qmldir), is it ok?

        • I don't understand this part, what is its purpose:

        !equals(_PRO_FILE_PWD_, $$OUT_PWD) {
            copy_qmldir.target = $$OUT_PWD/qmldir
            copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
            copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\"
            QMAKE_EXTRA_TARGETS += copy_qmldir
            PRE_TARGETDEPS += $$copy_qmldir.target
        }
        

        Thank you very much.

        Best Regards,
        DAvide Bruenlli

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 5 Jan 2019, 16:17 last edited by
          #4

          Did you download the example & built it ? It has usage example in the same directory.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • D Offline
            D Offline
            davidino
            wrote on 5 Jan 2019, 17:09 last edited by
            #5

            Hello @dheerendra,
            now I see it. The programs works as expected,
            I'm a little surprised that if in UseQMLPlugin main.cpp file, I comment out the engine.addImportPath(..), the program works even without it.
            Can you also give some details about previous questions? (except question number 1, which is satisfied)

            Thank you.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dheerendra
              Qt Champions 2022
              wrote on 5 Jan 2019, 17:14 last edited by
              #6

              qmldir should be there.
              It is copying qmldir

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              1 Reply Last reply
              1

              1/6

              31 Dec 2018, 11:48

              • Login

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