[Qt-interest] Qt Designer widget properties for custom widget without a designer plugin

Kustaa Nyholm Kustaa.Nyholm at planmeca.com
Thu Sep 2 16:28:17 CEST 2010


Hi,

I created a custom buttom widget derived from QPushButton.

For this button I've implemented a property 'planStyle' as follows:

        Q_PROPERTY(QString mPlanStyle READ planStyle WRITE setPlanStyle)

I then edit my xxx.ui file so that I have something like

    <widget class="PlanRadioButton" name="OFFbutton" native="true">
      <property name="planStyle">
      <string notr="true">right</string>
     </property>


I compile and it all works, the property is set etc etc.

when I look inside ui_xxx.h I see:

        OFFbutton->setPlanStyle(QString::fromUtf8("right"));


But if I edit my xxx.ui with Designer the .ui file changes to:

     <property name="planStyle" stdset="0">
      <string notr="true">right</string>
     </property>

Note the stdset="0" and the code generated by uis is now:

        
AUTObutton->setProperty("planStyle",QVariant(QString::fromUtf8("mid")));


So the property becomes dynamic property.

I could live with that but it looks wrong and inefficient for this purpose,
so is there anyway, short of writing a Designer plugin, to tell the Designer
not to add that 'stdset="0"' definition that seems to change the property
to a dynamic property?


br Kusti






More information about the Qt-interest-old mailing list