[PyQt] unhandled AttributeError in GraphicsItem.boundingRect()

Sergo Pogosyan sergo.pogosyan at gmail.com
Tue May 19 22:31:32 BST 2009


Hi all!

I have boundingRect() function in my GraphicsItem and it doesn't work
with class members.

When function returns explicitly constructed QRectF everything goes fine -

def boundingRect(self):
    return QtCore.QRectF((150/-2) - 1, (50/-2) - 1, 150 + 2, 50 + 2)

but when I want to calculate rectangle using class members -

def boundingRect(self):
    margin = 1
    tempBoundRect = QtCore.QRectF(0, 0, self.nodeWidth, self.nodeHeight)
    tempBoundRect.translate(-tempRect.center())
    return tempBoundRect.adjusted(-margin,  -margin,  margin,  margin))

- it fails, saying unhandled AttributeError nodeWidth.
Can't find anything about it. May be it's something obvious.
Thank you.


More information about the PyQt mailing list