[PyQt] Re: unhandled AttributeError in GraphicsItem.boundingRect()
Sergo Pogosyan
sergo.pogosyan at gmail.com
Wed May 20 12:44:05 BST 2009
Seems like I've found the problem - some of my class members were not
declared in __init__ function. After I've moved them to __init__
everything works fine.
On Wed, May 20, 2009 at 1:31 AM, Sergo Pogosyan
<sergo.pogosyan at gmail.com> wrote:
> 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