0
votes

I'm trying to add items to qgraphicsscene, and move them later. I am using QMainWindow and QFrames to organize content of window and I can add items, but can't move the items. In tutorials I have found authors use QDialog and QgraphicsView as the only widget. Is that what makes the difference ? QMainWindow does not pass mouse events to GraphicsView or QGraphicsScene ? Any help appreciated.

def _add_area(self):
  item = QGraphicsRectItem(0, 0, 100, 100)
  brush = QBrush()
  brush.setStyle(Qt.Dense7Pattern)
  brush.setColor(Qt.darkBlue)
  item.setBrush(brush)
  item.setFlag(QGraphicsItem.ItemIsMovable)
  item.setFlag(QGraphicsItem.ItemIsSelectable)
  self._scene.addItem(item)
1
Understood. If you want get good answer from someone then add your current code and add tags which shows is that you use python.Kosovan
sorry, my bad, problem is not python related though. when I code logic in C++ it behaves the same.Łukasz

1 Answers

0
votes

Ok, it seems I've found solution. When I removed QGraphicsView from QFrame it started working ( now QWidget is the parent of graphicsview ).