Adding a custom widget to Qt Designer

I have the following custom widget:

class QDESIGNER_WIDGET_EXPORT MySpecialButton : public QAbstractButton { Q_OBJECT ...etc... }; 

The Qt designer recognizes this widget, and I can place it in my form without any problems. However, when viewed in the property editor, only the QObject and QWidget properties are visible. How to make Qt Designer recognize that it is also a QAbstractButton object?

+4
source share
1 answer

First, make sure that there is a Q_OBJECT macro in the class Q_OBJECT . Also make sure the file was correctly moc ed. If none of these help, you can find out how QPushButton and QToolButton are declared to see if this gives you any hints.

Finally, if you need a chainsaw approach rather than a scalpel, you can define the properties that you want to set in your class by providing QAbstractButton functions as those that invoke the properties. Q_PROPERTY macro.

+2
source

All Articles