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

control the angle

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 3 Posters 683 Views 2 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.
  • C Offline
    C Offline
    chris_rookie
    wrote on last edited by
    #1

    I saw an example of qml. UI Components: Dial Control Example.
    I don't understand how to caculate the angel.

    1 Reply Last reply
    0
    • IntruderExcluderI Offline
      IntruderExcluderI Offline
      IntruderExcluder
      wrote on last edited by
      #2

      The angle property is read-only, instead of this you should use value property.

      C 2 Replies Last reply
      0
      • IntruderExcluderI IntruderExcluder

        The angle property is read-only, instead of this you should use value property.

        C Offline
        C Offline
        chris_rookie
        wrote on last edited by
        #3

        @IntruderExcluder
        Yes. I know what you mean.
        Here is the code.I just don't know "angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)" mean.

        Image {
            id: needle
            x: 98; y: 33
            antialiasing: true
            source: "needle.png"
            transform: Rotation {
                id: needleRotation
                origin.x: 5; origin.y: 65
                //! [needle angle]
                **angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)**
                Behavior on angle {
                    SpringAnimation {
                        spring: 1.4
                        damping: .15
                    }
                }
                //! [needle angle]
            }
        }
        
        Pablo J. RoginaP 1 Reply Last reply
        0
        • C chris_rookie

          @IntruderExcluder
          Yes. I know what you mean.
          Here is the code.I just don't know "angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)" mean.

          Image {
              id: needle
              x: 98; y: 33
              antialiasing: true
              source: "needle.png"
              transform: Rotation {
                  id: needleRotation
                  origin.x: 5; origin.y: 65
                  //! [needle angle]
                  **angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)**
                  Behavior on angle {
                      SpringAnimation {
                          spring: 1.4
                          damping: .15
                      }
                  }
                  //! [needle angle]
              }
          }
          
          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @chris_rookie said in control the angle:

          I just don't know "angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)" mean.

          It's a formula to calculate the angle for drawing the needle :-)

          And the angle is then used to animate a Behavior:

          A Behavior defines the default animation to be applied whenever a particular property value changes.

          In your case the property that changes is angle which in turn is dependent on root.value

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          C 1 Reply Last reply
          2
          • Pablo J. RoginaP Pablo J. Rogina

            @chris_rookie said in control the angle:

            I just don't know "angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)" mean.

            It's a formula to calculate the angle for drawing the needle :-)

            And the angle is then used to animate a Behavior:

            A Behavior defines the default animation to be applied whenever a particular property value changes.

            In your case the property that changes is angle which in turn is dependent on root.value

            C Offline
            C Offline
            chris_rookie
            wrote on last edited by
            #5

            @Pablo-J-Rogina
            Thanks for your answer.
            After reading this page ```
            https://doc.qt.io/qt-5/qml-qtquick-rotation.html

            I think I understand what "angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)" mean
            1 Reply Last reply
            0
            • IntruderExcluderI IntruderExcluder

              The angle property is read-only, instead of this you should use value property.

              C Offline
              C Offline
              chris_rookie
              wrote on last edited by
              #6

              @IntruderExcluder
              Thanks for your answer.

              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