How to update QApplicationWindow when hidden?



  • I'm experiencing a weird issue when I'm hiding and showing qml windows. I want to update the layout before I show it again but it shows the old state/data for a split second before updating and showing the new data. Like if I press a button and hide it within that buttons onClick handler, when I show the window it will show the buttons pressed animation finishing from where it left off when it was hidden.

    Is there any way to force updates on a hidden window? Or some workaround I can use? Thanks.

    I've tried the requestUpdate function and then qApp->processEvents(), but it doesn't seem to do anything.



  • @Eventh hi,
    I don't have this behavior with qml Button type, nor with custom button (Rectangle with Mousearea ..)
    QtQuick 2.5
    QtQuick.Window 2.2
    QtQuick.Controls 2.2

    How do you hide the window ?
    all this work for me : show(), hide() setVisible(bool), close(), opacity=x ?
    Maybe show the structure, how the window is created ?

    import QtQuick 2.5
    import QtQuick.Window 2.2
    import QtQuick.Controls 2.2
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        Button{
            id:showBtn
            onClicked:w.show() //w.setVisible(true)
        }
        Window{
            id:w
            visible: true
            width: 300
            height: 300
           Rectangle{
               id:btn
               scale: ms.pressed?0.7:1
               anchors.centerIn:parent
               height:showBtn.implicitHeight
               width:showBtn.implicitWidth
               color: "olive"
               Behavior on scale{NumberAnimation{duration: 50}}
                MouseArea{
                    id:ms
                    anchors.fill: parent
                    onClicked:w.close()//w.opacity=0//w.hide()//w.setVisible(false)
                }
           }
        }
    }
    

Log in to reply
 

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