[PyQt] Connecting two QGraphicsItems

Mads kofoden at yahoo.com
Mon Apr 6 15:13:36 BST 2009

Hi marcell

well in fact what I need is having, saying, three circles placed on one line of a rectangle. So when the rectangles is added there will be attached 3 circles to a specific line(see below bad drawing). 

|                       |
|                       |

each item needs to have separate functionality, so you should be able to set different attributes on each item. Is the createItemGroup, still the best way forward?



----- Original Message ----
From: Marcell Mars <marcell.mars at gmail.com>
To: pyqt at riverbankcomputing.com
Sent: Monday, April 6, 2009 3:30:07 PM
Subject: Re: [PyQt] Connecting two QGraphicsItems

On Mon, Apr 6, 2009 at 3:07 PM, Mads <kofoden at yahoo.com> wrote:
> I hope someone can help me witth this problem. It is probably straight forward
> I have a QGraphicsItem and a QGraphicsEllipseItem, when I add the QGraphicsItem to th
> graphicsview I want the QGraphicsEllipseItem to be added as well and be connected with
> the QGraphicsItem. So if you drag the QGraphicsItem around the QGraphicsEllipseItem
> will follow.

QGraphicsScene has method createItemGroup:


and by setFlag method you set QGraphicsItem.ItemIsMovable flag...


so your code could look like this:

myItemGroup = myScene.createItemGroup([myGraphicsItem, myEllipseItem])

hope it helps..
PyQt mailing list    PyQt at riverbankcomputing.com


More information about the PyQt mailing list