[PyQt] QGraphicsObject setGeometry with QGraphicsRectItem setRect

Harsha Rani ranishashi at gmail.com
Fri Jun 23 23:58:55 BST 2017

I am having problem in setting setGeomtry of QGraphicsObject with setRect
of QGraphicsRectItem to the same position. (QGraphicsRectItem inturn
inherited from QGraphicsObject)

I have many QGraphicsItems types, so I have a single QGObj
(QGraphicsObject) class that can share a QObject class for signal and slot.

I have small snippet below, may be my implementation is wrong or what I am
trying to archive may not be possible or setting the parameter is/are wrong.

The flow of my work is
widget -> class *OuterItem* (parent is "widget") ->
class *innerItem* (parent is "OuterItem") ->
class *childItem* (parent is "innerItem")

1. *OuterItem* is grey color rect
2.* innerItem *is blue color rect

to setRect for "*OuterItem*" is calculated using

to setRect/setGeometry  for "*innerItem*" class is
I have a question:

1. Blue rectangle box should start drawing the rectangle from "*topchild*",
one can see that there is displayment in the topleft corner,
but  bottonleft corner get it right.

This is b'cos *innerItem*.childrenBoundingRect() would also contain
QGraphicsRectitem of GrpItem,
this is can be overcome by re-calculationg manually.

Assume I got this (in the file line 300) and when I tried to set setGeomtry
and setRect then there is mismatch, after this mismatch, if I click on to
the *innerItem *(bluecolor) one can see that object is not selected (It
should display as __main__innerItem

And I need to keep this object *innerItem* inherited from QGObj (which is
inherited from QGraphicsObject)

What I am doing wrong in setting the QGraphicsRectItem (setRect) and
QGraphicsObject (setGeomtry).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170624/c0425b89/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: boundary.py
Type: text/x-python
Size: 14274 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170624/c0425b89/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: b64ndary.png
Type: image/png
Size: 10301 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170624/c0425b89/attachment-0001.png>

More information about the PyQt mailing list