1

I'm using Qt (Pyside in Python to get bindings), and am trying to get the frame geometry of a widget. When I try to get the frame geometry of the widget on startup and draw elements on the widget, it returns this:

PySide.QtCore.QSize(639, 479)

However, this is the incorrect frame geometry. If I redraw some elements on the widget, I get this:

PySide.QtCore.QSize(1044, 571)

The second output is the correct frame geometry, not the first one. According to this article: http://doc.qt.io/qt-4.8/application-windows.html, it states:

On X11, a window does not have a frame until the window manager decorates it. This happens asynchronously at some point in time after calling QWidget::show() and the first paint event the window receives, or it does not happen at all. Bear in mind that X11 is policy-free (others call it flexible). Thus you cannot make any safe assumption about the decoration frame your window will get. Basic rule: There's always one user who uses a window manager that breaks your assumption, and who will complain to you.

I think I'm not getting correct frame information because the window hasn't been decorated yet. Is there a workaround to this problem?

4

1 回答 1

1

Only workaround I know and it seems to worked for me several times then I faced same issue was:

 pWidget->show();
 pWidget->hide();

 pWidget->whatever geometry method
于 2013-08-09T11:21:56.260 回答