Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions

Image blinking



  • i want button image blinking when i clicked button and again clicked button stop blinking image in qml .can anybody give solution about this.



  • @satyanarayana143 hi

     Rectangle{
            id:btn
            color: "blue"
            height: 60
            width: 60
    
            property bool blink : false
    
            MouseArea{
                anchors.fill: parent
                onClicked: btn.blink = !btn.blink
            }
    
            ColorAnimation on color{
                from : btn.color
                to: Qt.lighter(btn.color)            
                duration: 200
                running: btn.blink
                loops : Animation.Infinite
                onRunningChanged: if(!running){btn.color = "blue"} // reset 
            }
        }
    

    you can use same approach to apply a color overlay if this is for an image



  • not colour change image blinking



  • @LeLev said in Image blinking:

    you can use same approach to apply a color overlay if this is for an image

        
        Item {
            width: 300
            height: 300
            MouseArea{
                anchors.fill: parent
                onClicked:  img.blink = !img.blink                        
            }
    
            Image {
                id: img
                source: "info.png"
                sourceSize: Qt.size(parent.width, parent.height)
                smooth: true
                visible: false
                property bool blink : false
            }
    
            ColorOverlay {
                id:co
                anchors.fill: img
                source: img
                color: "#80000000"
    
                ColorAnimation on color{
                    from:"#00080000"
                    to:"#80000000"
                    duration: 200
                    running: img.blink
                    loops : Animation.Infinite
                    onRunningChanged: if(!running){co.color = "#00080000"} // reset
                }
    
            }
        }
    


  • again u given ColorOverlay and ColorAnimation i am asking image should blink and stop not color image

    like voice recorder in windows when click start it will blink and we stop it will stop like that



  • @satyanarayana143 ok, no idea what do you mean then..



  • when we click and stop on windows voice recorder like that functionality in qml


Log in to reply