Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QtQuickControls2 AbstractButton autoRepeat not working for me

QtQuickControls2 AbstractButton autoRepeat not working for me

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 776 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lynettar 0
    wrote on last edited by lynettar 0
    #1

    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");
                    }
                }
            }
        }
    }
    
    
    J.HilkJ 1 Reply Last reply
    0
    • L lynettar 0

      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");
                      }
                  }
              }
          }
      }
      
      
      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      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)


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3
      • L Offline
        L Offline
        lynettar 0
        wrote on last edited by
        #3

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

        J.HilkJ 1 Reply Last reply
        0
        • L lynettar 0

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

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @lynettar-0
          great 👍

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

          don‘t forget to set the topic to solved


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved