[PyQt] Bug in QWidget.geometry()?

Nathan Weston nathan at genarts.com
Wed Feb 29 16:29:38 GMT 2012

According to the Qt docs, QWidget.geometry() should return the geometry 
of the widget itself, not including the window border. But I'm finding 
that's not the case -- geometry() is including the borders and returning 
the same value as frameGeometry().

However, setGeometry() behaves as documented, which has the interesting 
side effect that window.setGeometry(window.geometry()) moves the window!

I'm using Qt 4.8.0 and PyQt 4.9 on Windows 7.

The attached test program demonstrates the problem. I use move() (which 
*does* account for window borders) to position the window at the upper 
left of the screen. But then a call to self.setGeometry(self.geometry()) 
moves the window off screen.

Interestingly, the value of geometry() is the same before and after the 
call to setGeometry(), despite the fact that the window has moved on screen.

. . . . . . . . . . . . . . . . . . . . . . . . .
Nathan Weston                   nathan at genarts.com
GenArts, Inc.                   Tel: 617-492-2888
955 Mass. Ave                   Fax: 617-492-2852
Cambridge, MA 02139 USA         www.genarts.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: geometry-bug.py
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120229/af4477a8/attachment.ksh>

More information about the PyQt mailing list