My custom widget does not appear in Qt Designer
-
I followed https://doc.qt.io/qt-6/qtdesigner-customwidgetplugin-example.html building in VS2022 and placed the DLL in the plugins/designer folder but it is not been picked up by Qt Designer when I open Qt Designer. I was expecting a separate section for my widget but nothing is displayed...
Could I be missing any actions when working in VS2022?
The example instructions use CMake - I have translated them to a VS project file as best I could...
What could be the reasons the plugin does not show in the toolabar set?
-
@Pl45m4 Simply copying the dll is fine. The loaded plugins can be seen in the designer under Help -> Plugins. The plugin must be compiled with the same Qt version as Qt designer.
-
Assuming your code is correct, to what location did you built your plugin?
e.g.$QTDIR/plugins/designer
on Windows.The example instructions use CMake - I have translated them to a VS project file as best I could...
You translated CMake to VS?! What do you mean?
CMake is a build system like MakeFile or Qt's QMake. So I think you use one of them. -
@Pl45m4 Should I create a QML file in Visual Studio and fill it with :
CONFIG += plugin TEMPLATE = lib QT += widgets uiplugin HEADERS = analogclock.h \ customwidgetplugin.h SOURCES = analogclock.cpp \ customwidgetplugin.cpp OTHER_FILES += analogclock.json TARGET = $$qtLibraryTarget($$TARGET) target.path = $$[QT_INSTALL_PLUGINS]/designer INSTALLS += target
and then compile it with qmake?w
would it be a QML file (qml) or a QML module definition file (qmldir)?
BUT, I don't have a analogclock.json file!!! is this important?
OR: how do I add a CMakeLists.txt file to my VS2022 project?
and make it compile? -
Nothing of what you write above makes sense.
So you want to create a Designer plugin with QML? I dont think this is possible. QtDesigner is for QtWidgets only.and then compile it with qmake?
You don't compile with QMake, CMake etc.
These are used to configure what to do with your compiled project... whether you create a library, what additional things have to be linked and where to build/install it.
You compile with your, well, compiler... e.g. MinGW, MSVC or GCC, etc.how do I add a CMakeLists.txt file to my VS2022 project?
If you have a CMake project, you should already have one, if you don't use CMake, you don't need one.
-
@Pl45m4 I apologize for the confusion. Here is what I did: I opened the .pro file with VS Tools:
root/examples/designer/customwidgetplugin/customwidgetplugin.pro
and compiled the resulting VS project. Then I placed the resulting DLL in the plugins/designer folder ( U:\Qt\6.6.2\msvc2019_64\plugins\designer)... I opened Qt Designer from within VS and there is no customwidget in the toolbar!! :-(
So even following the .pro file, I am not gettings a plugin configured correctly...
-
@jdent said in My custom widget does not appear in Qt Designer:
I opened the .pro file with VS Tools:
root/examples/designer/customwidgetplugin/customwidgetplugin.proSo you use QMake
Then I placed the resulting DLL in the plugins/designer folder ( U:\Qt\6.6.2\msvc2019_64\plugins\designer).
I don't know if placing it manually will work. The documenation says you have to install it there, so there might be some more files than just the library.
I opened Qt Designer from within VS and there is no customwidget in the toolbar!! :-(
Is the QtDesigner you open from VS Tools the same Designer which came with Qt and where you install your plugin?
-
@Pl45m4 Simply copying the dll is fine. The loaded plugins can be seen in the designer under Help -> Plugins. The plugin must be compiled with the same Qt version as Qt designer.
-
@Christian-Ehrlicher I found the problem: I was placing a debug version of the plugin!!
Now that I compiled with release it appears in Qt Designer!! GREAT!! Thanks!! -