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. DelayButton reset after activation

DelayButton reset after activation

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 989 Views
  • 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    I want to use a DelayButton to avoid accidental clicks, but I'm not interested in the checkable feature. Hence, once activated I want to un-check it to be ready to a new press.

    I tried to do this, but it does't work:

    DelayButton {
        text: "RESET"                
        onActivated: { 
            // do something
            checked = false 
        }
    }
    

    also set the checkable property to false in the definition doesn't work. What is the right way to do this?

    DiracsbracketD 1 Reply Last reply
    0
    • M Mark81

      I want to use a DelayButton to avoid accidental clicks, but I'm not interested in the checkable feature. Hence, once activated I want to un-check it to be ready to a new press.

      I tried to do this, but it does't work:

      DelayButton {
          text: "RESET"                
          onActivated: { 
              // do something
              checked = false 
          }
      }
      

      also set the checkable property to false in the definition doesn't work. What is the right way to do this?

      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by
      #2

      Hi @Mark81
      I tried on Windows 10 (x64) and Qt versions 5.10.0, 5.10.1 and 5.11.0 and setting checked = false works?

      After activation and releasing the button, the state is reset and I can press it again until it triggers.

      import QtQuick 2.10
      import QtQuick.Window 2.3
      import QtQuick.Extras 1.4
      
      //ApplicationWindow {
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          DelayButton {
              delay: 1000
              text: "RESET"
      
              onActivated: {
                  console.debug("Activated!")
                  checked = false
              }
          }
      }
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mark81
        wrote on last edited by Mark81
        #3

        Found the problem. I'm using the DelayButton from QtQuick.Controls instead of the one in QtQuick.Extras because I like the rectangular shape rather than the circular one and I'm using other object from Controls. But the behavior is different, though.

        I find confusing to have the same object in two different imports... I don't know if I can live with the "extras" one. Please, would you try the very same code with:

        import QtQuick.Controls 2.2
        

        to try if it doesn't work as expected now?

        DiracsbracketD 1 Reply Last reply
        0
        • M Mark81

          Found the problem. I'm using the DelayButton from QtQuick.Controls instead of the one in QtQuick.Extras because I like the rectangular shape rather than the circular one and I'm using other object from Controls. But the behavior is different, though.

          I find confusing to have the same object in two different imports... I don't know if I can live with the "extras" one. Please, would you try the very same code with:

          import QtQuick.Controls 2.2
          

          to try if it doesn't work as expected now?

          DiracsbracketD Offline
          DiracsbracketD Offline
          Diracsbracket
          wrote on last edited by Diracsbracket
          #4

          @Mark81
          I didn't see your message because you did not directly reply to mine (or I did not get the notification), hence the delay.
          This delay did hence not come from the button^^.

          I tried with import QtQuick.Controls 2.2 and then indeed I get the same behavior as you are experiencing.

          However, I achieved the reset by simply using:

                  onActivated: {
                      console.debug("Activated!")
                      progress = 0.0
                  }
          

          Although the online Qt doc says that the progress property is read-only, it is not!
          http://doc.qt.io/qt-5/qml-qtquick-controls2-delaybutton.html

          I found a hint for this by looking at the source code:
          https://code.woboq.org/qt5/qtquickcontrols2/src/quicktemplates2/qquickdelaybutton.cpp.html#_ZN17QQuickDelayButton11setProgressEd

          Since it has a setProgress method I reckoned that it also must be exposed to QML which it apparently is. I did not look at the header file for closure about this, but since it works...

          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