Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Restored window after minimizing is not maximized



  • I'm trying to implement my own window frame for a desktop application. I have already done the borders and the top bar. There are only buttons what's left. So the problem is that my window restores windowed after minimizing even being at the Maximized state before minimizing.
    Here is my code for buttons:
    Maximizing button:

    onReleased:
    {
        mx_btn.highlighted = false
        if(app_window.visibility == 2) // Windowed
            app_window.showMaximized()
        else
            app_window.showNormal()
    }
    

    Minimizing button:

    onReleased:
    {
        mn_btn.highlighted = false
        app_window.showMinimized()
    }
    

    Application window props:

    ApplicationWindow
    {
        id: app_window
       
        ...
    
        flags: Qt.Window | Qt.FramelessWindowHint
        visible: true
    
        ...
    
        visibility: isFullWindow? Window.Maximized : Window.Windowed
    
        ...
    }
    


  • I have no better idea than to rewrite all this stuff to QtWidgets with native support. I'll try to embed the main context using QML, but the window will be QtWidgets.



  • Omg, I've just ORed the flags, and now it works as intended.
    In QtWidgets it should be:

    	// To set the window minimized
    	setWindowState(windowState() & ~Qt::WindowActive | Qt::WindowMinimized);
    	// To restore the window from minimized state
    	setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
    

    So in QML it should work in the same way.