ShowMaximized call works but the MainWindows is resized on app.exec()
-
Hi everybody,
I’m upgrading my software from Qt 4.7.4 to Qt 5.4.0 Beta (I’m waiting for the release the 9th Dec). I'm on Windows 7 and my application is in Win32.
It doesn't happen in the Qt 4.7.4. I can't reproduce it with a simple empty project.
In my MainWindow, I have 2 tabbed vertical dockwidgets and a custom QWidget in centralwidget.
It's append only on two similar applications (the inherit of the same AbstractMainWindow). Another who inherit of the same base class doesn't have this issue, mainly because it has a horizontal dockwidget. I found a work around by add then hiding a horizontal dockwidget but it stays a very dirty work around.
The issue: when I call myMainWindow.showMaximized(), I see, with debug breakpoint, the mainwindow fills the screen like the attemped behavior. Unfortunately, during the app.exec() call, the mainwindow is resized BUT the windowState stays at Maximized...
I really don't understand what can append, I watch the resize method and apparently the width and height have decrease before the first resize called during theapp.exec() method.
It seems the QWidget::width() and QWidget::height() method don't return the same value as the QWidget::crect field, which is correct.
The QMainWindowTabBar, on his destruction (why destruction... I don't know: I haven't TabBar), raises a event and this call a QWidget::SetMinimizeSize. Like the value return by QWidget::height() and QWidget::width() are not correct and less than the wanted minimum size, my MainWindow is resized.
My hypothesis is: it's come from the qwindows.dll who misunderstood the windows Handle value.
But I'm want some others point of view before posting a bug report.
Have you seen this behavior? Have any advice, please?
-
Up, please
-
Hi,
Can you reduce your code base in order to easily reproduce that bug ?
-
I confirm this bug even on 5.15.2
I cannot reproduce it 100% but sometimes it works ok sometimes exactly as you say. Even the windows maximize icon changes to un-maximize as it "thinks" window is maximized. see the icon between _ and x top right corner
Somehow it can be fixed when playing with ui editor and modifying MainWindow size there.... I think... -
I found it !
In qtcretor when you hit a button to restore the default mainwidow size the section with geometry disappears and causes this bug.
When the geometry is specified (as below) all works fine. The misleading part is that when you restore mainwindow default size it automatically is filled with the total width/height coming from the internal widgets/layoutsThe workarond is to increase the Width and Height in the rows below at least by 1 pixel and the section is restored.
ui content after restoring size to defaults
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="enabled"> <bool>true</bool> </property> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="windowTitle">
proper ui content:
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="enabled"> <bool>true</bool> </property> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1711</width> <height>1111</height> </rect> </property> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property>