1

I have a QGraphicsScene and a few QGraphicsItem objects on it. It is a data flow diagram.

I want to tie a few objects (input and output ports) to scene borders, and when scene size changes, they should automatically move with the scene bord

enter image description here Cannot you tell me, how can it be done?

Felix
  • 3,351
  • 6
  • 40
  • 68
  • Are you sure you're wanting to tie it to the scene "border", or do you actually mean that you want to tie them to the edge of the QGraphicsView that is visualizing some area of the scene? The difference is important if you're supporting panning and zooming, where the view may visualize only a subset of the scene. – goug Apr 03 '17 at 17:40

1 Answers1

1

Bind a method in the QGraphicsItem implementation to the sceneRectChanged signal of the scene object, and have that method adjust it's object's position to take into account the new scene rect.

Depending on what you are trying to do, you might need to keep a copy of the previous scene rect for reference so you can work out what the change is.

Simon Hibbs
  • 5,941
  • 5
  • 26
  • 32