Behavior of “geometry” Property and “show” Method in PySide

I am developing applications that runs on Linux and Windows using PySide. In the process, I recently, so embarrassed a lot for the behavior of the “geometry” property of QMainWindow differs between Windows and Linux, so I investigated in detail.


I wanted to do the following.

After the minimize, maximize, and full screen sized the main window, I want to know the current size of the window by code.

By running the QWidget.showMaximized / Minimized / FullScreen method, it is possible to change the window size to be displayed. (In the reference, there is a description indicating that showFullScreen() may not work well with X Window. But there is no inconvenience for now in use my range.) However, as described below, to know the display size from the current code, it works well on Windows, but it did not work on Linux.

How to Investigate

I have created the program that, by running each method show, showMaximized, showMinimized, showFullScreen, showNormal and setGeometry for QMainWindow, you can see how “geometry” property change. (Because it is unable to verify the value while displaying the window if you run the method before event loop, I made the methods run with delay of 100msec by QTimer. (Because the windows are displayed, the screen flickers a little at run time.)


Here are the results of running, in the above-mentioned, on Windows7, Xubunutu13.04 and Ubunutu13.04 in the same PC (with VirtualBox environment: Host Windows, Guset Linux) with a screen size of 1920×1080. I listed the value of the “geometry” of the property at each stage. (It cut the redundant part of the actual display.)

The values of the QRect are, the first two are the position (the coordinates of the upper left) and the following two are the size (width x length).

On Windows

On Xubuntu/Ubuntu

The results on Ubuntu and Xubuntu were the same.


From the above results, I’ve found the following facts about “geometry” property.

  • Both on Windows and Linux, the value before running show() is (0, 0, 640, 480). (I think that it is VGA size).
  • After running show(), size is changed to 200×100 on both OS. However, the display position differs by OS. On Linux, it is the upper-left corner. And on Windows, it is shifted slightly to the lower right.
  • On Windows, after running showMaximized/FullScreen/Normal, “geometry” is set to the size of the window that is actually displayed. However, on Linux, those methods do not change the “geometry”.(Display itself is changed to be maximize or full sized or normalized. These facts mean that the value of the “geometry” and the actual window that is displayed does not match.)
  • showMinimized() method does not change “geometry” on Windows (also Linux). Perhaps, it seems that minimize is equivalent to be invisible.
  • Of course, setGeometry change the “geometry” on both OS.

From these results, you can find that on Windows you can know the current window size from “geometry” property, but there is a possibility that the current window size does not match the “geometry” in the case of Linux. On Linux, if you want to match the window size and the “geometry”, you should culculate the size of your own and run setGeometry().

[Related Site]

[Related Articles]

[Referenced Sites]

Your email address will not be published.