Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Promoting a widget in Qt Designer
krzysieklfc last edited by krzysieklfc
I want to promote QWidget to custom widget derived from it. The problem is that the widget expects more arguments to be passed to the constructor and in the generated ui_ file only the parent is passed:
//constructor is: QmaxRollup (int category=ROLLUP_CAT_STANDARD, QWidget *parent=nullptr) //generated: widget_1 = new MaxSDK::QmaxRollup(Form);
error C2664: 'MaxSDK::QmaxRollup::QmaxRollup(const MaxSDK::QmaxRollup &)': cannot convert argument 1 from 'QWidget *' to 'int'
The documentation says:
[...] It exposes properties such as title and category, so they can be easily set in code or in the Qt Designer.
I already set dynamic properties to the widget in my form, but it doesn't change anything.
Header file is available here.
What you can do is initialise
categorydirectly in the constructor with the
ROLLUP_CAT_STANDARDvalue and add a setter to your class to modify that property.
You can then do that in your code somewhere more suitable.
krzysieklfc last edited by
Thanks for answer
The class is implemented in static library so I don't think I can cleanly change the source code. I'm just wondering if I can initialize it directly in form to keep things consistent.
If not, I can always add the widget to the UI after the form is created.
Whether it's a dynamic or static library doesn't really matter. If you have control on it, you can modify the widget and rebuild the library.