Results 1 to 2 of 2

Thread: custom plugin designer property with out a variable?

  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 custom plugin designer property with out a variable?

    Hi,

    I made a custom designer plugin, which has a vector that holds various states.
    But at design time (in designer) only the first element of the vector needs to be initilized.
    Now, the Q_PROPERTY() macro needs a delcleration of a variable type and the variable name that holds the property (as far as I know), which forces me to declare an extra variable to receive the property value from designer, and then asign that variable in to the vector.
    My question is, is there a way to assign the a value from the Q_PROPERTY() macro on to the vector without a intermidiate variable?

    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: custom plugin designer property with out a variable?

    Quote Originally Posted by high_flyer
    Now, the Q_PROPERTY() macro needs a delcleration of a variable type and the variable name that holds the property (as far as I know), which forces me to declare an extra variable to receive the property value from designer, and then asign that variable in to the vector.
    Q_PROPERTY works in a bit different way.

    Suppose you have:
    Qt Code:
    1. Q_PROPERTY( int x READ x WRITE setX )
    To copy to clipboard, switch view to plain text mode 
    This declares a property named "x" of int type. If Qt wants to assign a value for this property it will invoke the setX() method and when it wants to retrieve its value --- it will use the x() method. Qt doesn't know (and doesn't care) where do you actually store this property's value.

    You can even write:
    Qt Code:
    1. Q_PROPERTY( unsigned int size READ size )
    2. //...
    3. unsigned int size() const
    4. {
    5. return someDataStructure.size();
    6. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to jacek for this useful post:

    high_flyer (15th March 2006)

Similar Threads

  1. problem loading custom plugin on Qt Designer 4
    By raman_31181 in forum Qt Tools
    Replies: 18
    Last Post: 26th September 2008, 10:42
  2. Replies: 6
    Last Post: 14th April 2007, 08:59
  3. Replies: 15
    Last Post: 25th March 2007, 04:40
  4. Replies: 13
    Last Post: 15th December 2006, 12:52
  5. QPixmap designer property not showing up
    By high_flyer in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2006, 20:56

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.