
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:
Q_PROPERTY( int x READ x WRITE setX )
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:
Q_PROPERTY( unsigned int size READ size )
//...
unsigned int size() const
{
return someDataStructure.size();
}
Q_PROPERTY( unsigned int size READ size )
//...
unsigned int size() const
{
return someDataStructure.size();
}
To copy to clipboard, switch view to plain text mode
Bookmarks