QGraphicsItem::itemChange nerver called
-
Hi
I've been building a new QDeclarativeItem and I'm currently trying to spy on my child with QGraphicsItem::itemChange (I've overloaded it). But this function is never called whether I moved a child or I added one. Is there something special to do or something else ?
-
Do you set QGraphicsItem::ItemSendsGeometryChanges flag?
-
With this flag enable the function is called in different occasion like @ItemFlagsChange
ItemFlagsHaveChanged
ItemChildAddedChange
ItemSceneChange
ItemSceneHasChanged@But never when my children move. I will try to connect to xChanged signal.
Edit : I've found a way to make it work @QVariant Line::itemChange ( GraphicsItemChange change, const QVariant & value )
{
if(change == QGraphicsItem::ItemChildAddedChange)
{
QGraphicsItem* item = value.value<QGraphicsItem*>();
QDeclarativeItem* item2 = dynamic_cast<QDeclarativeItem*>(item);
QList<QObject*> loc_o_childrens = children();
foreach(QObject* obj,loc_o_childrens)
{
QDeclarativeItem* child = dynamic_cast<QDeclarativeItem*>(obj);
if(child == item2)
{
connect(child,SIGNAL(xChanged()),this,SLOT(repaint()));
connect(child,SIGNAL(yChanged()),this,SLOT(repaint()));
}
}}
return QGraphicsItem::itemChange(change, value);
}@I really dislike this way of doing things but I can't get the ItemPositionChange.