[PyQt] understanding SIGNALS and SLOTS

Christopher M. Nahler christopher.nahler at papermodels.at
Thu May 27 14:02:51 BST 2010


I have worked with shortcut signals so far. The way I used this was to
self.emit(SIGNAL("someText"), variable)
and to use this variable by
self.connect(sending.object, SIGNAL("someText"), some.function)
where some.function has an argument which it can then use.

Now I would like to use the position of an graphicsItem in one scene to 
drive/update the position of another graphicsItem in another scene. More 
specific: I have 3 scenes (top, front, side). When I move a bar 
(rectangle) in the groundScene it should update a bar/rectangle in 
another scene.

What is the best way to do this?

Now I have a MyData class object that holds the positions and that is 
pointed to in each scene. But I would like it to work with setValue(int) 
and valueChanged(int) signals and slots. Is this only possible for 
predefined QT code or can this be added like this in Python?

Also what confuses me is that graphicsItems cannot emit (if I understand 
correctly). Do I have to wrap them in an own QObject derived class 
object and do the signaling there?

Any tips and pointers are much appreciated
Chris


More information about the PyQt mailing list