QtQuickControls2 AbstractButton autoRepeat not working for me

  • Hello,

    I'm trying to make use of the autoRepeat feature of AbstractButton in 5.12.2. I am experimenting with the gallery example to test the function of auto repeat. I have modified the "First" button on ButtonPage.qml to make it autoRepeat with interval and delay set small. When I run this code I see no repeat of onPressed, onPressAndHold, or onClicked as evidenced by only one console.log statement. What am I missing? Here is the code that I have modified:

    ScrollablePage {
        id: page
        Column {
            spacing: 40
            width: parent.width
            ColumnLayout {
                spacing: 20
                anchors.horizontalCenter: parent.horizontalCenter
                Button {
                    text: "First"
                    Layout.fillWidth: true
                    autoRepeat: true
    //                autoRepeatDelay: 50
    //                autoRepeatInterval: 50
                    MouseArea {
                        anchors.fill: parent
                        onPressed: console.log ("First Button pressed");
                        onPressAndHold: console.log ("First Button press and hold");
                        onClicked: console.log ("first button clicked");
                        onReleased: console.log ("first button released");

  • Moderators

    hi @lynettar-0 and welcome

    from what I can see, you're mixing stuff up. The Button qml- object already has a MouseArea and you set the auto repeat to true on that one.
    But than you create a 2nd MouseArea that covers the whole button. that one has the autoRepeat not set to true (the default is off)

  • Oh my! I can't believe that I made such a bonehead mistake. Thank you! Commenting out the additional MouseArea did the trick!

  • Moderators

    great 👍

    something like that happens to everyone, we don‘t like to admit it however ;)

    don‘t forget to set the topic to solved

Log in to reply