qtqmlwindow-resizeminimizedframeless

Minimizing window issue in Qt 5.15


Window {
    id: mainWindow

    width: 960
    height: 600

    flags:  Qt.FramelessWindowHint | Qt.WindowMinimizeButtonHint | Qt.Window

    Rectangle {
        width: 15
        height: 15

        anchors {
            top: parent.top
            left: parent.left
            
            topMargin: 10
            leftMargin: 910
        }

        SvgImage {
            width: 11
            height: 2

            source: "images/Collapse.svg"

            anchors {
                centerIn: parent
            }
        }

        MouseArea {
            id: mouse
    
            anchors {
                fill: parent
            }
            
            onPressed: {
                mainWindow.showMinimized()
            }
        }
     
        Timer {
            repeat: true
            interval: 1000
            running: true

            onTriggered: {
                console.log("mouse.pressed = ", mouse.pressed);
            }
        }
    }
}

I faced an issue with Qt.FramelessWindowHint. After using showMinimized() function I restore the window but then any click on window causes minimizing window again. mouseArea never gets pressed. I tried putting Timer printing mouse.pressed valueand it's false all the time. I found the several links on this issue but there's no solution except going to fullscreen when restoring window. My application always stays the same size and never goes to fullscreen.

https://www.qtcentre.org/threads/33298-Qt-FramelessWindowHint-qgraphicsview-qgraphicwidget-showminimized-problem

https://www.qtcentre.org/threads/42641-QML-rendering-problems-after-showMinimized()

QML: rendering problems after showMinimized()

Maybe you could give me a hint for workaround. Btw I'm using Qt 5.15


Solution

  • Use onClicked insted of onPressed inside the MouseArea.