moswald
moswald

Reputation: 11677

Adding a Custom Widget to Qt Designer

I've got the following custom widget:

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

Qt Designer recognizes this widget, and I can place it onto my form without a problem. However, when looking in the property editor, only the QObject and QWidget properties are visible. How do I get Qt Designer to recognize that this is also a QAbstractButton object?

Upvotes: 4

Views: 2628

Answers (1)

Caleb Huitt - cjhuitt
Caleb Huitt - cjhuitt

Reputation: 14941

First, make sure you have the Q_OBJECT macro in your class definition. Also, make sure the file was properly moced. If neither of those help, you might investigate how QPushButton and QToolButton are declared to see if that gives you any hints.

Finally, if you need a chainsaw approach rather than a scalpel, you could define the properties you want to set in your class, giving the QAbstractButton functions as the ones to call for the properties. Look into the Q_PROPERTY macro.

Upvotes: 2

Related Questions