Automatic touch simulation on rectangle component in QML



  • I wanted to simulate automatic click event on rectangle component in QML code.

    I have requirement as bellow.
    .qml file:

    import QtQuick 2.6
    import QtQuick 2.6
    import QtQuick.Window 2.2
    import QtQuick.Controls 2.1
    import QtQuick.Controls 2.1
    Window {
    id :root
    visible: true
    width: 640
    height: 480

    Rectangle{
        id:child1
        color: "green"
        height: 100
        width:100
        x:20
        y:60
        MouseArea{
            visible: true
            anchors.fill: parent
            id:child1MA
            onClicked: {
                console.log("Clicked")
            }
    

    Timer {
    interval: 2000
    repeat: false
    running: true
    onTriggered:
    //call function simulate touch here//
    }
    }
    }

    so when click simulation happens on rectangle, "Clicked" message has to log on consol

    thank you

    Edit raven-worx: moved topic



  • Mouse Area has signals and signals can be called directly. Based on your condition you can call the MouseArea signals directly.


Log in to reply
 

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