I am using Qt5 Creator for an app, and in the main window's constructor I call this->setWindowState(Qt::WindowMaximized)
. The radio buttons and the check box work fine (i.e. easily toggle between checked and unchecked) when the window is initially maximized.
However, if I minimize it and maximize it then the radio buttons and the check box seem to freeze and don't freely toggle. But if I do restore down again things become fine.
I tried including a this->update
in the slots of the radio buttons and check box but that didn't work. Any help would be appreciated.
When you use
this->setWindowState(Qt::WindowMaximized);
you are possibly overriding other states property of the windows. In particular, you are removingQt::WindowActive
. So use either ofBut I wonder why you are playing around with window state. Can't you use
show()
in the constructor to make your window visible?Try
this->showMaximized()
instead. The window state is available for doing tricky things that aren't possible through any other method, but if another method provides the desired functionality (QWidget::showMaximized() in this case) use that instead.I encountered similar problem
Environment: Windows7 + Qt5.3 + Frameless QMainWindow
What I did: Minimized window with
QMainWindow::showMinimized
then shown it again.What happened: Window stopped redrawing. It looked frozen.
I was debugging it and found out following:
After minimizing window attribute
Qt::WA_Mapped
was removed from QMainWindow (you can set breakpoint tosetAttribute_internal
inqwidget.cpp
to check it). But this attribute was not set again after showing window. This caused that conditionif (discardSyncRequest(tlw, tlwExtra))
inQWidgetBackingStore::sync
was not met and it causeddirtyWidgets
are not cleared. In other part of Qt updating system this caused that no other rendering was made.Workaround I did: Subclassed
QMainWindow
and set attributeQt::WA_Mapped
manually when window was restored (handling changeEvent):This works for me well. Right solution would be probably fixing the bug in Qt.
More about the problem
I found similar bug in Qt project history (marked as closed): QTBUG-34147
Also similar question in Qt forum: Minimizing frameless windows...
I found this comment beside the mentioned condition in
QWidgetBackingStore::sync
It seems that there was a bug in Qt kernel (maybe mentioned QTBUG-34147) which was solved, but there remained some issues around it.