Integrating Custom Widgets with Qt Designer
-
-
@tomy said in Integrating Custom Widgets with Qt Designer:
I would like if we want to use a custom widget, say, that iconEditor, we could have it like any other widget in the widget box and would drag and drop and use it.
That's what the first link is for: http://doc.qt.io/qt-5/designer-creating-custom-widgets.html
While it looks cool, in my experience, most of the time you won't bother using it in production code and just go for the promote solution as it's quicker. I would go as far as to suggest you just skip to the next part of the book as Qt Designer plugins are huge niche.
Does it mean that we can use a pushButton as an iconEditor that way!?
Not really, the iconEditor would need to be a subclass of QPushButton for that to work. since all widgets are subclasses of QWidget, you can always use that safely
-
Also as a note to Designer plugin.
Since you are using mingw compiler, a full blown plugin for Designer will not just work.The reason for that is a Designer plugin is a DLL and for Creator to load it, it must be made
with SAME version of compiler as Creator was.On windows, it means you must be using visual studio compiler and not mingw.
This not a restriction from Qt. its how DLLS works and goes for all frameworks.
The only cure is to compile a new Creator with mingw OR use visual studio compiler.The promotion feature offer a easier way to use a custom widget in an UI file and
is far less work.
You can drag it back to the widget list to have as the other widgets. ( after you promote it)
Its under "Scratch pad" label. (in bottom) -
-
@VRonin
So we could conclude that if we write Qt programs by hand code we won't be able to use the promotion approach, and we will be led to the plugin approach. This approach too is not very handy because the issues it has as mrjj spotted them. Right? -
Hi
Just to be clear
Promotion is a feature to allow a custom widget to be used in Designer with UI files.It is basically a Replace at Runtime feature allowing you to design UI files with your customs widgets
without having to make them full blown Designer plugins. ( which is far more work )
Using promotion , you can draw the GUI using Designer and it will use your custom widget when run.I use promotion all the time. Its one of my favorite features allowing me both to use custom widgets AND
use Designer for drawing the GUI.
If you use Designer, its a feature you will want to use. :) -
@tomy said in Integrating Custom Widgets with Qt Designer:
Right?
No. I never use Qt Designer to build my ui but just do everything by hand, for example:
QWidget mainWid; auto mainLay = new QVBoxLayout(&mainWid); mainLay->addWidget(new QLabel("Test Label",&mainWid)); mainLay->addWidget(new QPushButton("Useless Button",&mainWid)); mainWid.show();
If, instead, you use Qt Designer, promotion will be almost impossible to avoid.
Designer plugins are only really relevant if you are developing widgets for other programmers to use and you want nice integration with Qt Designer, for example: http://www.devmachines.com/qtitandatagrid-overview.html