PDA

View Full Version : QDeclarativItem::update() does not work



BigFastAndrey
5th May 2012, 06:09
Hello everybody.

I want to write a simple QML item that extends QDeclarativeItem and represents a sector (http://en.wikipedia.org/wiki/Circular_sector).

Several properties are defined in my class


Q_PROPERTY( QColor color READ color WRITE setColor )
Q_PROPERTY( double width READ width WRITE setWidth )
Q_PROPERTY( double height READ height WRITE setHeight )
Q_PROPERTY( double startAngle READ startAngle WRITE setStartAngle )
Q_PROPERTY( double spanAngle READ spanAngle WRITE setSpanAngle )
Q_PROPERTY( double opacity READ opacity WRITE setOpacity )

Each of them has its own setter and getter.

I suggest item should be updated when "spanAngle" property is modified by calling "setSpanAngle" method. Therefore I put update() invocation in it:

void setSpanAngle( double spanAngle )
{
mSpanAngle = spanAngle;
update( 0, 0, mWidth, mHeight ); // UPDATE HERE
}

In fact, update does not occur when setSpanAngle is called. But if I resize parent window it updates. (see video http://www.sendspace.com/file/gq9dn4)

Does anyone knows the reason of such behavior?

wysota
6th May 2012, 14:52
What if you just call update() without any parameters? Also how did you define boundingRect() for your item?