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

Samuel Gaist samuel.gaist at cinetis.ch
Fri Sep 3 11:31:58 CEST 2010


Sorry sent to private address...

Begin forwarded message:

> From: Samuel Gaist <samuel.gaist at cinetis.ch>
> Date: 3 septembre 2010 09:03:42 GMT+02:00
> To: Kustaa Nyholm <Kustaa.Nyholm at planmeca.com>
> Subject: Re: [Qt-interest] Qt Designer widget properties for custom  
> widget without a designer plugin
>
> On 2 sept. 10, at 16:28, Kustaa Nyholm wrote:
>
>> 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
>>
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest

Hi,
AFAIK it might be that line that is wrong
>       Q_PROPERTY(QString mPlanStyle READ planStyle WRITE setPlanStyle)
mPlanStyle look like a variable name to me and it should be the  
property name, you might have better luck with
>       Q_PROPERTY(QString planStyle READ planStyle WRITE setPlanStyle)

Hope this helps
Samuel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1587 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100903/4ef0190a/attachment.bin 


More information about the Qt-interest-old mailing list