[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Bug in QWidget.geometry()?
From:       Nathan Weston <nathan () genarts ! com>
Date:       2012-02-29 16:29:38
Message-ID: 4F4E5272.2050004 () genarts ! com
[Download RAW message or body]

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@genarts.com
GenArts, Inc.                   Tel: 617-492-2888
955 Mass. Ave                   Fax: 617-492-2852
Cambridge, MA 02139 USA         www.genarts.com

["geometry-bug.py" (text/plain)]

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic