Results 1 to 3 of 3

Thread: How to initialize properties to a custom plugin widget?

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default How to initialize properties to a custom plugin widget?

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to initialize properties to a custom plugin widget?

    This is a part of .ui file that uses Qwt widgets:
    xml Code:
    1. <property name="orientation" >
    2. <enum>Qt::Horizontal</enum>
    3. </property>
    4. <property name="frameShadow" >
    5. <enum>QwtDial::Raised</enum>
    6. </property>
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to initialize properties to a custom plugin widget?

    ofcourse!!
    What a good idea, i just saved an ui file with my custom widget and all is there to see :-)
    THANKS!

Similar Threads

  1. Replies: 5
    Last Post: 21st February 2007, 22:11
  2. Replies: 2
    Last Post: 25th August 2006, 11:35
  3. Custom Widget Plugin Analog Clock
    By kemp in forum Qt Programming
    Replies: 8
    Last Post: 11th August 2006, 13:22
  4. Replies: 5
    Last Post: 16th May 2006, 20:38
  5. Replies: 12
    Last Post: 15th February 2006, 10:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.