Please do not reply by quoting my entire response. It makes the thread extremely long and difficult to read. Just click Reply, then add QUOTE tags for specific things. Thanks.
I wanted to do it in the Qt Designer environment through the properties of my widget.
OK, I am pretty sure the problem is in the domXml() method of your plugin. The XML code is supposed to be a template that Qt Designer uses when writing the widget's specification to the .ui file. I think your mistake is including all of the enum values in this XML, when there should only be one as a placeholder. So your domXml() should look like this:
{
return uR"(
<ui language="c++">
<widget class="QLed" name="qLed">
)"
R"(
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>50</width>
<height>50</height>
</rect>
</property>
")
R"(
<property name="toolTip">
<string>Binary Led</string>
</property>
<property name="value">
<bool>false</bool>
</property>
<property name="whatsThis">
<string>Led widget</string>
</property>
<property name="onColor">
<enum>QLed::Red</enum>
</property>
<property name="offColor">
<enum>QLed::Grey</enum>
</property>
<property name="shape">
<enum>QLed::Circle</enum>
</property>
</widget>
</ui>
)"_s;
}
QString QLedPlugin::domXml() const
{
return uR"(
<ui language="c++">
<widget class="QLed" name="qLed">
)"
R"(
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>50</width>
<height>50</height>
</rect>
</property>
")
R"(
<property name="toolTip">
<string>Binary Led</string>
</property>
<property name="value">
<bool>false</bool>
</property>
<property name="whatsThis">
<string>Led widget</string>
</property>
<property name="onColor">
<enum>QLed::Red</enum>
</property>
<property name="offColor">
<enum>QLed::Grey</enum>
</property>
<property name="shape">
<enum>QLed::Circle</enum>
</property>
</widget>
</ui>
)"_s;
}
To copy to clipboard, switch view to plain text mode
Qt Designer will understand from your Q_ENUM() and Q_PROPERTY() definitions what are the allowed values to substitute for the placeholder values in the template.
The Qt Designer UI file format is here. Near the bottom of the page is the specification for the Property type, which specifies what the <property> element can contain.
<xs:complexType name="Property">
<xs:choice>
<xs:element name="bool" type="xs:string" />
<xs:element name="color" type="Color" />
<xs:element name="cstring" type="xs:string" />
<xs:element name="cursor" type="xs:integer" />
<xs:element name="cursorshape" type="xs:string" />
<xs:element name="enum" type="xs:string" />
<xs:element name="font" type ="Font" />
<xs:element name="iconset" type="ResourceIcon"/>
<xs:element name="pixmap" type="ResourcePixmap" />
<xs:element name="palette" type="Palette" />
<xs:element name="point" type="Point" />
<xs:element name="rect" type="Rect" />
<xs:element name="set" type="xs:string" />
<xs:element name="locale" type="Locale" />
<xs:element name="sizepolicy" type="SizePolicy" />
<xs:element name="size" type="Size" />
<xs:element name="string" type="String" />
<xs:element name="stringlist" type="StringList" />
<xs:element name="number" type="xs:integer" />
<xs:element name="float" type="xs:float" />
<xs:element name="double" type="xs:double" />
<xs:element name="date" type="Date" />
<xs:element name="time" type="Time" />
<xs:element name="datetime" type="DateTime" />
<xs:element name="pointf" type="PointF" />
<xs:element name="rectf" type="RectF" />
<xs:element name="sizef" type="SizeF" />
<xs:element name="longlong" type="xs:long" />
<xs:element name="char" type="Char" />
<xs:element name="url" type="Url" />
<xs:element name="uint" type="xs:unsignedInt" />
<xs:element name="ulonglong" type="xs:unsignedLong" />
<xs:element name="brush" type="Brush" />
</xs:choice>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="stdset" type="xs:integer" />
</xs:complexType>
<xs:complexType name="Property">
<xs:choice>
<xs:element name="bool" type="xs:string" />
<xs:element name="color" type="Color" />
<xs:element name="cstring" type="xs:string" />
<xs:element name="cursor" type="xs:integer" />
<xs:element name="cursorshape" type="xs:string" />
<xs:element name="enum" type="xs:string" />
<xs:element name="font" type ="Font" />
<xs:element name="iconset" type="ResourceIcon"/>
<xs:element name="pixmap" type="ResourcePixmap" />
<xs:element name="palette" type="Palette" />
<xs:element name="point" type="Point" />
<xs:element name="rect" type="Rect" />
<xs:element name="set" type="xs:string" />
<xs:element name="locale" type="Locale" />
<xs:element name="sizepolicy" type="SizePolicy" />
<xs:element name="size" type="Size" />
<xs:element name="string" type="String" />
<xs:element name="stringlist" type="StringList" />
<xs:element name="number" type="xs:integer" />
<xs:element name="float" type="xs:float" />
<xs:element name="double" type="xs:double" />
<xs:element name="date" type="Date" />
<xs:element name="time" type="Time" />
<xs:element name="datetime" type="DateTime" />
<xs:element name="pointf" type="PointF" />
<xs:element name="rectf" type="RectF" />
<xs:element name="sizef" type="SizeF" />
<xs:element name="longlong" type="xs:long" />
<xs:element name="char" type="Char" />
<xs:element name="url" type="Url" />
<xs:element name="uint" type="xs:unsignedInt" />
<xs:element name="ulonglong" type="xs:unsignedLong" />
<xs:element name="brush" type="Brush" />
</xs:choice>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="stdset" type="xs:integer" />
</xs:complexType>
To copy to clipboard, switch view to plain text mode
The first part is an <xs:choice> element, which means that only one of the elements listed can appear in the <property> element. In other words, listing more than one <enum> entry violates the <ui> XML specification. So Qt Designer imported your plugin, but probably ignored the incorrect parts of your domXml().
Bookmarks