What really happening after setWindowState(Qt::WindowMinimized)? Problem with restore to normal form.



  • I have tray icon in application but whenever I minimalize my application(frameless) I can't restore it to work normally. I used installEventFilter to operate on Tabs in my app and after I restore it from minimized form Nothing from this is working. Other works fine only those items I used filterEvent on them does not.
    Any solutions?

    I do like:

    -hookFilterEvents();
    -add tray icon

    -on changeEvent
    -> check if its minimalize -> icon show message
    ->if its maximilize (here is a problem so I try to find solutions)

    I checked:
    this->setWindowState(false);
    this->showNormal();
    this->raise();
    this->activateWindow();
    this->show();
    and other and nything helped. Maybe minimize do something more than just set a flag on our window?



  • And again I answer myself:

    Problem was with flags of frameless window. After we catch window state change event other than minimize we have to restart flags and show window, something like refreshing flags. Maybe someone will find it helpfull.

    @void MainWindow::changeEvent( QEvent* e )
    {

    if( e->type() == QEvent::WindowStateChange)
    {
        if(this->windowState() & Qt::WindowMinimized )
        {
            //do something after minimize
        }
        else
        {
            setWindowFlags(Qt::Window);//set normal window flag
            setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);//and return to your old flags
    
            this->showNormal();
        }
    }
    

    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.