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                   nat...@genarts.com
GenArts, Inc.                   Tel: 617-492-2888
955 Mass. Ave                   Fax: 617-492-2852
Cambridge, MA 02139 USA         www.genarts.com
from PyQt4.QtGui import QApplication
from PyQt4.QtGui import QWidget
import PyQt4.pyqtconfig

class MyWindow(QWidget):
    def __init__(self):
        super(QWidget, self).__init__()

        self.move(0,0)
        print self.geometry()
        self.setGeometry(self.geometry())
        print self.geometry()

app = QApplication([])
w = MyWindow()
w.show()
app.exec_()
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to