Qt World Summit: Submit your Presentation

Custom Widgets Plugins: QT_INSTALL_PLUGIN not working on Windows 7 & Bug in Qt 5.6 Custom Widget Interface template

  • I am quite new to Qt and I would like to build a Custom Widget Plugin for the Qt-Designer. I am running Qt 5.6 on Windows 7.

    I have tried to follow the examples in the Qt-tutorials and other tutorials, but I cannot get it working yet. It seems as if the libraries that should be generated with the build are not written into the correct target directory, which I have set in the .pro file:

    CONFIG += plugin debug_and_release
    TARGET = $$qtLibraryTarget(levelmeterplugin)
    TEMPLATE = lib

    HEADERS = levelmeterplugin.h
    SOURCES = levelmeterplugin.cpp
    RESOURCES = icons.qrc
    LIBS += -L.

    greaterThan(QT_MAJOR_VERSION, 4) {
    QT += designer
    } else {
    CONFIG += designer

    #target.path = C:/Qt/5.6/mingw49_32/plugins/designer
    #target.path = C:/Users/chd/Documents/Qt_Software/Qt_Designer_Widgets
    target.path = $$[QT_INSTALL_PLUGINS]/designer
    INSTALLS += target

    I have added my custom library directory to the QT_INSTALL_PLUGINS environment viariable and I have also added the path to the plugins directory: C:/Qt/5.6/<compiler_name>/plugins/
    I have also tried to build the libraries without using the QT_INSTALL_PLUGIN directory.

    Although it seems as the environmental variables are set correctly, the libraries get built into the build debug directory of the widget and the widget is not available in Qt-Designer.

    I assume that Qt does not seem to use the target QT_INSTALL_PLUGIN settings, but I am not sure about this.

    Does anyone know what could cause this issue? How can I get Qt to use the QT_INSTALL_PLUGIN environmental variable?

    Any help or a link to a working clear step by step tutorial would be really apprecciated.

    PS: I have also noticed that Qt 5.6 offers a template for the interface for building a Custom Widget Plugin, but building the template interface produces an error on the compiler output due to a wrong include:
    #include <QtDesigner/QDesignerCustomWidgetInterface>

    This can be resolved with replacing this include with:
    #include <QtUiPlugin/QDesignerCustomWidgetInterface>

    I found this a bit confusing, as I actually would expect a template provided by Qt to work by default.

  • Lifetime Qt Champion

    @ghielmetti said:

    Hi and welcome


    You cannot make plugins for Designer with mingw unless u compile Creator yourself with same compiler.
    Creator is compiled with Visual Studio and you need to use that compiler to create plugins for it.
    (as far as i know) Its not Qt fault. just how DLLS works.

    If you want a plugin just to be able to place it visually, you can do that with the promote feature and
    skip the whole plugin part.
    But if u want to adjust properties design time, then u need plugin.

  • @mrjj Thank you for your reply.
    I will compile the plugin with msvc2013 and see if I get it working. I have promoted a widget and this seems to work. However, for some reason sometimes Qt can not find the paths to my promoted widgets' .h and .cpp files that I set in the .pro file. But it works if I copy the files into the project manually.

  • Lifetime Qt Champion

    Normally I do have the .h file in the project folder and point to that in the
    Promote dialog.
    Im not sure it will take a full path in the dialog but I never tried :)