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 Updated to NodeBB v4.3 + New Features

rectangular DelayButton

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 625 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.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on 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
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on 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
      • gfxxG Offline
        gfxxG Offline
        gfxx
        wrote on 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

        ODБOïO 1 Reply Last reply
        0
        • gfxxG gfxx

          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

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

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

          gfxxG 1 Reply Last reply
          0
          • ODБOïO ODБOï

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

            gfxxG Offline
            gfxxG Offline
            gfxx
            wrote on 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

            gfxxG 2 Replies Last reply
            0
            • gfxxG gfxx

              @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

              gfxxG Offline
              gfxxG Offline
              gfxx
              wrote on 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
              • gfxxG gfxx

                @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

                gfxxG Offline
                gfxxG Offline
                gfxx
                wrote on 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

                • Login

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