Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QGraphicsItem::itemChange nerver called
Forum Updated to NodeBB v4.3 + New Features

QGraphicsItem::itemChange nerver called

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Merinas
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexander
      wrote on last edited by
      #2

      Do you set QGraphicsItem::ItemSendsGeometryChanges flag?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Merinas
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved