Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Deployment and development issues of programs using Qt Quick plug-ins



  • Question 1 The qmldir file is not copied to the output directory

    There is such a configuration in the plug-in project generated by the wizard

    !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
    }
    

    I printed two environment variables PRO_FILE_PWD and OUT_PWD, they are different.

    message($$_PRO_FILE_PWD_)
    message($$OUT_PWD)
    

    But when I compile the plug-in project, the qmldir file is not copied to the output directory.

    E:\Documents\Repositories\temporary\build-quick-plugin-test-Desktop_Qt_5_14_2_MSVC2017_32bit-Debug\Clipboard\debug
    $ ls -l
    total 2061
    -rw-r--r-- 1 Administrator 197121  110485 11月 26 11:47 clipboard.obj
    -rw-r--r-- 1 Administrator 197121  176156 11月 26 11:47 clipboard_plugin.obj
    -rwxr-xr-x 1 Administrator 197121   78848 11月 26 11:47 Clipboardd.dll*
    -rw-r--r-- 1 Administrator 197121     953 11月 26 11:47 Clipboardd.exp
    -rw-r--r-- 1 Administrator 197121  555328 11月 26 11:47 Clipboardd.ilk
    -rw-r--r-- 1 Administrator 197121    2040 11月 26 11:45 Clipboardd.lib
    -rw-r--r-- 1 Administrator 197121 1757184 11月 26 11:47 Clipboardd.pdb
    -rw-r--r-- 1 Administrator 197121 1699840 11月 26 11:47 Clipboardd.vc.pdb
    -rw-r--r-- 1 Administrator 197121    2809 11月 26 11:47 moc_clipboard.cpp
    -rw-r--r-- 1 Administrator 197121  107251 11月 26 11:47 moc_clipboard.obj
    -rw-r--r-- 1 Administrator 197121    3818 11月 26 11:47 moc_clipboard_plugin.cpp
    -rw-r--r-- 1 Administrator 197121  109750 11月 26 11:47 moc_clipboard_plugin.obj
    -rw-r--r-- 1 Administrator 197121     260 11月 26 11:47 moc_predefs.h
    

    Question 2 How to publish custom plug-ins following the main program?

    I manually set the plugin directory, and copied the qmldir file to this directory after building the plugin.

    DESTDIR = $$PWD/imports/ClipBoard
    

    The final directory structure after generation is as follows:

    E:\Documents\Repositories\temporary\quick-plugin-test\Clipboard\imports\ClipBoard
    $ ls -l
    total 1029
    -rwxr-xr-x 1 Administrator 197121   78848 11月 26 11:52 Clipboardd.dll*
    -rw-r--r-- 1 Administrator 197121     999 11月 26 11:52 Clipboardd.exp
    -rw-r--r-- 1 Administrator 197121  555756 11月 26 11:52 Clipboardd.ilk
    -rw-r--r-- 1 Administrator 197121    2040 11月 26 11:52 Clipboardd.lib
    -rw-r--r-- 1 Administrator 197121 1740800 11月 26 11:52 Clipboardd.pdb
    -rw-r--r-- 1 Administrator 197121      36 11月 26 11:44 qmldir
    

    In the .pro file of the test project, I configured the plugin path

    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH = $$PWD/../Clipboard/imports
    

    I imported my plugin in the test code.

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import ClipBoard 1.0
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
    
        ClipBoard {
            id: clipboard
        }
    }
    

    The compilation is passed, but the following error is prompted when I run:

    QQmlApplicationEngine failed to load component
    qrc:/main.qml:3:1: module "ClipBoard" is not installed
    

    I realized that I needed to deploy the plug-in to the running directory of the test program, and then I copied the entire directory of imports/Clipboard to the output directory of the test program, and it could run normally after running it again.

    My questions:

    • How to configure the test project to always have access to the latest plug-in file during debugging instead of manually copying it.
    • When the test program needs to be released, how can I deploy my application and plug-in through windeployqt or macdeployqt without manually copying the plug-in directory


  • Create a makefile using .pro for ex: qmake sample.pro .You will get a MakeFile.Then run make and make install -> this command will install the plug-in in the corresponding director with correct inputs in .pro file.


Log in to reply