I have an application with some windows, and one of them is modal. On Windows OS, when I minimize the modal window all other windows minimize as well. On Linux (I'm using Astra Linux) only the modal window minimizes and all other windows state doesn't change, and they are not available for any action, like if they were disabled. What's wrong with me or Astra Linux? How can I do same minimize-action in Astra Linux?
Asked
Active
Viewed 329 times
1 Answers
0
You may want to override the changeEvent
method of the modal widget to catch a WindowStateChange
event, check the widget state and, if minimized, force all other top level widgets to minimize as well (if not, restore all windows):
#include <QEvent>
#include <QApplication>
void Form::changeEvent(QEvent * event)
{
if(event->type() == QEvent::WindowStateChange)
{
QWidgetList list = QApplication::topLevelWidgets();
if(isMinimized())
{
for(int i=0; i<list.size(); i++)
{
if(!list.at(i)->isMinimized())
{
list[i]->setWindowState(Qt::WindowMinimized);
}
}
}
else
{
for(int i=0; i<list.size(); i++)
{
if(list.at(i)->isMinimized())
{
list[i]->activateWindow();
//or:
//list[i]->setWindowState(Qt::WindowActive);
}
}
}
}
}

p-a-o-l-o
- 9,807
- 2
- 22
- 35
-
Ok. I'm starting test this. – Kortunov Dmitry Mar 15 '18 at 11:12
-
@AARez I added some code to restore all windows when the modal gets restored. – p-a-o-l-o Mar 15 '18 at 11:39
-
Thx bro! I will test this today. – Kortunov Dmitry Mar 15 '18 at 12:29
-
Method "activateWindow()" don't work. Better need to write this: "setWindowState(Qt::WindowActive)" – Kortunov Dmitry Mar 16 '18 at 07:32