PDA

View Full Version : How to initialize properties to a custom plugin widget?



high_flyer
28th February 2006, 16:06
Hi,

I made a custom widget pluging, that has some properties of basic types such as 'int' but also some enums.
I would like to give these properties default values, but I don't understand how to do it the xml way.
Here is what I have:
bool m_snapToCursor
int m_markSize
MarkStyle m_markStyle
What would be the xml line to set these with defaluts?

I tried the following:
" <property name=\"m_snapToCursor\" >\n"
" <bool>false</bool>"
" </property>\n"
" <property name=\"m_markSize\" >\n"
" <int>8</int>"
" </property>\n"
" <property name=\"m_markStyle\" >\n"
" <MarkStyle>PKnob::Line</MarkStyle>"
" </property>\n"

But designer just ingnores it, and puts what ever grabage is currently in memory for these properties.
A pointer to the right place in the docs would be also appreciated, since I couldn't find so far anything that speaks about it.
In QDesignerCustomWidgetInterface Class Reference there is only the warning about the supported QVariants...

Thanks in advance.

jacek
28th February 2006, 16:15
This is a part of .ui file that uses Qwt widgets:<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="frameShadow" >
<enum>QwtDial::Raised</enum>
</property>

high_flyer
28th February 2006, 16:56
ofcourse!!
What a good idea, i just saved an ui file with my custom widget and all is there to see :-)
THANKS!