Important: Please read the 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:

        mx_btn.highlighted = false
        if(app_window.visibility == 2) // Windowed

    Minimizing button:

        mn_btn.highlighted = false

    Application window props:

        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.