promoting "designer" widgets
-
It's been a long time since I've actually done any Qt coding, and prior there was a good bit of Qt-designer UI stuff run under pyqt.
I'm trying to remember if there is an easy "quick-n-dirty" way to use a UI designer widget within a larger designer UI interface. I think the way I hacked it before was to reserve space on the global UI as a QWidget and at object init/constructor of the UI I would reassigned the QWidget pointers to point to my custom UIs. It was ugly but it worked in python.
I have a complex widget that I need to duplicate four times on the larger UI (probly via an array) such that when I update any subwidget attributes the effects cascade throu the higher numbered ones in the array, and to an output view. The application is a paint/pigment mixing simulation that "correctly" deals with the subtractive nature of mixed pigments, as opposed to the additive light nature of the RGB color model used in computer graphics.
-
In Designer place four QWidgets into your layout and then select the "Promote to..." option for one of the widgets:
Tell Designer what class should be used in place of QWidget:
Click Add, then Promote
For the other Widgets you will have a shortcut menu to Promote them to the previously defined class. -
that works. Thanks!
but an annoyance with the designer GUI interface surfaced. The "Promoted Classes" dialog forces the header filename to be all lowercase, regardless of mixed case naming of the class itself. Somewhat annoying, and forced me to manually edit the xml.
-
@Kent-Dorfman said in promoting "designer" widgets:
The "Promoted Classes" dialog forces the header filename to be all lowercase
It does not force anything. It defaults the header file name to a lowercase version of the class name* but you can edit the value in the dialog to suit yourself. The file name does not need to be in any way derived from the class name.
- This is a very common, dare I say the overwhelming prevalent, naming system
-
That's not the behaviour I witnessed. upon changing th header name to mixed case and losing focus in that textedit field, it spontaneously changed it back to lowercase.
-
@Kent-Dorfman I have two versions of Qt 5 Designer and one Qt 6 Designer. All behave correctly on Linux.
What version of Designer are you using, and on what platform?
-
It is making a liar out of me now, but some combination of operations DID cause it to misbehave earlier.
My coding standard is a single class per header and use of hpp and cpp as extensions. Class name and header name must exactly match.
Using Debian11 so it is 5.15.2
Anyway, tis not important now.