Answer the question
In order to leave comments, you need to log in
How to group properties (PROPERTY) of a custom widget (custom widget plugin) for Qt Designer?
I am using Qt 5.3.1. You need to make your own widget, which you can put in Qt Designer. Qt uses a specific term for this: custom widget plugin. One of the requirements for it is to make it possible to customize it in Designer, and even in a certain way. It is necessary to make several groups of properties. By groups (maybe there is a more correct term - feel free to say) I mean such blocks of data: which can contain bool, string, int, etc. values.
Found two ways to set properties.
1) Qt XML
Documentation
Excerpt from there:
QString AnalogClockPlugin::domXml() const
{
return "<ui language=\"c++\">\n"
" <widget class=\"AnalogClock\" name=\"analogClock\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>100</width>\n"
" <height>100</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string>The current time</string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string>The analog clock widget displays the current time.</string>\n"
" </property>\n"
" </widget>\n"
"</ui>\n";
}
class QDESIGNER_WIDGET_EXPORT LED : public QWidget
{
Q_OBJECT
Q_PROPERTY(double diameter READ diameter WRITE setDiameter) // mm
Q_PROPERTY(QColor color READ color WRITE setColor)
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
Q_PROPERTY(bool state READ state WRITE setState)
Q_PROPERTY(bool flashing READ isFlashing WRITE setFlashing)
Q_PROPERTY(int flashRate READ flashRate WRITE setFlashRate)
Answer the question
In order to leave comments, you need to log in
QDesignerPropertySheetExtension creates groups like this:
And apparently, the grouping I need exists only for built-in types. Absolutely unhealthy.
Thanks for the direction
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question