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. rectangular DelayButton
Forum Update on Monday, May 27th 2025

rectangular DelayButton

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 611 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.
  • G Offline
    G Offline
    gfxx
    wrote on 3 Jun 2020, 19:57 last edited by
    #1

    is possible to make delay button rectangular whitout make a custom one? Not see style for .... but maybe there are some trik for make it. I appreciate any suggest.

    regards

    bkt

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Markkyboy
      wrote on 3 Jun 2020, 20:57 last edited by
      #2

      Try this;

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.12
      
      Window {
          visible: true
          width: 320
          height: 240
          title: qsTr("Rectangular button")
      
          DelayButton {
              delay: 2000
              text: "Button"
              anchors.centerIn: parent
          }
      }
      

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      1
      • G Offline
        G Offline
        gfxx
        wrote on 5 Jun 2020, 17:56 last edited by
        #3

        ok thanks ... sorry but i have active import QtQuick.Extras 1.4 in my file ..... so only round DelayButton .... but if cancel these module all works ....

        Other things not undestand how is possible to change color and backgroundcolor of delay button, for example yellow and red instead of grey and darkgray as standard style.

        thanks

        bkt

        O 1 Reply Last reply 5 Jun 2020, 19:26
        0
        • G gfxx
          5 Jun 2020, 17:56

          ok thanks ... sorry but i have active import QtQuick.Extras 1.4 in my file ..... so only round DelayButton .... but if cancel these module all works ....

          Other things not undestand how is possible to change color and backgroundcolor of delay button, for example yellow and red instead of grey and darkgray as standard style.

          thanks

          O Offline
          O Offline
          ODБOï
          wrote on 5 Jun 2020, 19:26 last edited by
          #4

          @gfxx hi
          see here https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-delaybutton

          G 1 Reply Last reply 6 Jun 2020, 04:45
          0
          • O ODБOï
            5 Jun 2020, 19:26

            @gfxx hi
            see here https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-delaybutton

            G Offline
            G Offline
            gfxx
            wrote on 6 Jun 2020, 04:45 last edited by
            #5

            @LeLev I see but need linear delaybutton shadow and not circular ... if try to use ctx.line(x,x,x,x,x,x) .... I receive an error for inexistent draw function .... and not find a page with permitted draw function ...

            thanks

            bkt

            G 2 Replies Last reply 6 Jun 2020, 10:35
            0
            • G gfxx
              6 Jun 2020, 04:45

              @LeLev I see but need linear delaybutton shadow and not circular ... if try to use ctx.line(x,x,x,x,x,x) .... I receive an error for inexistent draw function .... and not find a page with permitted draw function ...

              thanks

              G Offline
              G Offline
              gfxx
              wrote on 6 Jun 2020, 10:35 last edited by
              #6

              @gfxx I try with these demo code but with no success ...

                      DelayButton {
                          id: delayPress
                          width: 100
                          height: 50
                          display: AbstractButton.TextOnly
                          delay: 3000
                          font.bold: true
                          anchors.top: parent.top
                          anchors.topMargin: 0
                          checkable: true
                          anchors.horizontalCenter: parent.horizontalCenter
                          opacity: delayPress.enabled? 1 : 0.3
                          visible: true
              
              
                          text: "Delay\nButton"
                              contentItem: Text {
                                  text: delayPress.text
                                  font: delayPress.font
                                  opacity: enabled ? 1.0 : 0.3
                                  color: "white"
                                  horizontalAlignment: Text.AlignHCenter
                                  verticalAlignment: Text.AlignVCenter
                                  elide: Text.ElideRight
                              }
              
                          background: Rectangle {
                              implicitWidth: delayPress.width
                              implicitHeight: delayPress.height
                              opacity: enabled ? 1 : 0.3
                              color: delayPress.down ? "#17a81a" : "#21be2b"
                              //border.color: "#2b6016"
                              //border.width: 1
                              antialiasing: true
                              radius: 2
              
                              anchors.centerIn: parent
              
                              Canvas {
                                  id: canvas
                                  anchors.fill: parent
              
                                  Connections {
                                      target: delayPress
                                      onProgressChanged: canvas.requestPaint()
                                  }
              
                                  onPaint: {
                                      var ctx = getContext("2d")
                                      ctx.clearRect(0, 0, delayPress.width, delayPress.height)
                                      ctx.strokeStyle = "red"
                                      ctx.beginPath()
                                      var startPoint = 0
                                      var endPoint = startPoint + delayPress.progress
                                      ctx.fillRect(startPoint, delayPress.height, endPoint, delayPress.height)
                                      ctx.stroke()
                                  }
                              }
                          }
              

              some suggest?

              bkt

              1 Reply Last reply
              0
              • G gfxx
                6 Jun 2020, 04:45

                @LeLev I see but need linear delaybutton shadow and not circular ... if try to use ctx.line(x,x,x,x,x,x) .... I receive an error for inexistent draw function .... and not find a page with permitted draw function ...

                thanks

                G Offline
                G Offline
                gfxx
                wrote on 8 Jun 2020, 13:07 last edited by
                #7

                @gfxx

                var endPoint = startPoint + delayPress.progress
                

                these row is wrong, because progress go from 0 to 1 so you need to multiply the variable "progress" by the length of the desired rectangle .... all this goes great.

                Thanks at all

                bkt

                1 Reply Last reply
                0

                1/7

                3 Jun 2020, 19:57

                • Login

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