[Qt-interest] properties order in Qt designer plugins
Giacomo
giacomo.strangolino at elettra.trieste.it
Tue Aug 11 16:35:29 CEST 2009
On Tuesday 11 August 2009 14:50:33 Friedemann Kleint wrote:
> Hi,
>
> > > In my designer widget plugin I have some Q_PROPERTies to personalize.
> > >
> > > I would like to know if there is a way to define an order in which
> > > those properties have to be executed.
> > >
> > > For esample, supposing that the widget plugin has two Q_PROPERTies:
> > >
> > > Q_PROPERTY(a, READ a WRITE setA,,)
> > >
> > > Q_PROPERTY(b, READ b WRITE setB,,)
>
> This issue exists in Qt as well. For example, if you set checkable=true on
> a QPushButton, you can set checked=true only after that call.
>
> The declaration in qabstractbutton.h looks like:
>
> Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
> Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE
> isCheckable ....)
>
> uic will set the properties in that order and all will work well. Note how
> the boolean DESIGNABLE function influences the enabling of the property in
> Qt Designer.
>
> Regards,
> Friedemann
First of all, many thanks.
I have a property that sets up a poller and a property that sets up a polling
period, and another one that sets up a read mode (defined in an enumeration)
setSource(QString sourceName)
setPeriod(int milliseconds)
setRefreshMode(enum mode)
While designing, I am free to change the source name and the source period
without constraints on which should be set first. The same goes for the mode.
Moreover, period and mode have their defaults, so while designing I am not
compeled to change them.
source property is DESIGNABLE false by default, and is set by a Custom
designer widget interface.
When I run the application, I need to always set mode and period before
starting the polling with the source name, for efficiency reasons.
So it is important that setSource() is called after the previous two, but
without restrictions during GUI design.
If I well understood your advice, I could force the uic to put the calls in
the desired order by setting the Q_PROPERTY like this, assuming that the
enumeration starts from 0 and the timeout is greater than 0:
Q_PROPERTY(int mode, READ mode, WRITE setMode DESIGNABLE true)
Q_PROPERTY(int period, READ period, WRITE setPeriod DESIGNABLE true)
Q_PROPERTY(QString source READ source WRITE setSource DESGNABLE period > 0 &&
mode > 0)
although I would like to maintain the property source DESIGNABLE false to go
on setting it through the custom widget interface.
Best regards and thanks again.
Giacomo.
Elettra - Synchrotron Light Radiation Facility - Trieste
http://www.elettra.trieste.it
More information about the Qt-interest-old
mailing list