Observe this simple scene example which puts two buttons on the scene:


Qt Code:
  1. auto ww = new QGraphicsProxyWidget();
  2. ww->setWidget(new QPushButton());
  3. ww->setPos(900, 900);
  4.  
  5. auto ww2 = new QGraphicsProxyWidget();
  6. ww2->setWidget(new QPushButton());
  7. ww2->setPos(500, 500);
  8.  
  9. auto scene = new QGraphicsScene();
  10. scene->addItem(ww);
  11. scene->addItem(ww2);
  12.  
  13. auto view = new QGraphicsView();
  14. view->resize(1000, 1000);
  15. view->setScene(scene);
  16. view->show();
To copy to clipboard, switch view to plain text mode 


Everything works fine, and the two buttons appear at the specified positions.

However, if we now add the itemismovable flag to them like so:


Qt Code:
  1. auto ww = new QGraphicsProxyWidget();
  2. ww->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
  3. ww->setWidget(new QPushButton());
  4. ww->setPos(900, 900);
  5.  
  6. auto ww2 = new QGraphicsProxyWidget();
  7. ww2->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
  8. ww2->setWidget(new QPushButton());
  9. ww2->setPos(500, 500);
  10.  
  11. ...
To copy to clipboard, switch view to plain text mode 



the the initial position of the items breaks. They both put over each other at position (0,0). However, if I call ww->setPos(...) after the view is shown, then that works.


Any idea what might be causing this?






Environment:

Qt 5.7
VS2013U5
Windows7SP1