QGraphicsPathItem display error after migration (Qt-4.8.6 -> Qt-5.5.1)



  • Hello,

    I have an other problem after my migration.
    When I move my item, I don't move the item group.

    1.With Qt4.8.6 :

    1. After I add my item, my windows display :
      0_1486385767000_QtForumImage4.png
    2. When I select my item :
      0_1486385895756_QtForumImage5.png
    3. When I deplace it :
      0_1486385962440_QtForumImage6.png

    1.With Qt5.5.1 :

    1. After I add my item, my windows display :
      0_1486386004651_QtForumImage1.png
    2. When I select my item :
      0_1486386020710_QtForumImage2.png
    3. When I deplace it :
      0_1486386026352_QtForumImage3.png
    ItemGroup::ItemGroup(QGraphicsItem* parent, QGraphicsScene* scene, const SimItem* item, QPointF position):
    #if (QT_VERSION >= QT_VERSION_5)
       QGraphicsItem(parent),
    #else
       QGraphicsItem(parent, scene),
    #endif
       _item(item)
    {
       QPainterPath p;
       p.addRoundedRect(position.x(), position.y(), 100, 30, 5, 5);
       setPath(p);
       setPen(QPen(_border));
       setBrush(QPen(_font));
       setFlags(QGraphicsItem::ItemIsMovable);
       setFlags(QGraphicsItem::ItemIsSelectable);
       _my_scene = scene;
       createOthersItems();
       
       setPos(position);
    }
    
    ItemGroup::createOthersItems()
    {
       for (int index = 0; index < _items->childCount(); ++index)
       {
          Item* child = _items->getChild(index);
          addItem(child);
       }
    }
    
    ItemGroup::addItem(const SimItem* item)
    {
       if ((item == NULL) || (_my_scene == NULL))
       {
          return NULL;
       }
       QFont font = _my_scene->font();
       Port* port = new Port(this, _my_scene, item);
    
       _my_scene->addItem(port);
       port->setBlock(this);
       port->setName("port name");
       font.setBold(true);
       _ports.push_back(port);
       QFontMetrics fm(font);
       QPainterPath p;
       p.addRoundedRect (...)
       setPath(p);
       setPos(...);
    }
    
    Port::Port(QGraphicsItem* parent, QGraphicsScene* scene, const SimItem* item):
       QGraphicsItem(parent),
       _item(item)
    {
       _label = new QGraphicTextItem(this);
       ...
       _my_scene = scene;
    }
    

    I know that the origine of my problem is the inheritit of QGraphicsPathItem, but howa correct it ??

    If someone can help me. I would be very grateful.

    e822104


  • Qt Champions 2016

    Hi
    Image upload is broken. We cannot see them. Please use external site and paste links here :)



  • @mrjj
    Problem solved. I will loader my picture After and explain how I solved my problem.
    Thanks you


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.