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. Pl Explain math in Dial qml example
Qt 6.11 is out! See what's new in the release blog

Pl Explain math in Dial qml example

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 5.2k 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.
  • P Offline
    P Offline
    profuma
    wrote on last edited by
    #1

    Hi,
    In Qt SDK 1.1 (Dial control example) Dial.qml the angle of needle is represented by

    angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)

    where did the -130,130,133 value come from? Why is a factor of 2.6 used?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Aesthetics probably. Angles between -130 and +133 are shown. This whole thing results in root.value being a number between 0 and (133 + 130)/2.6, which is 263/2.6 ~= 100.

      So given that information, it is all about scaling a 0-100 value to range that looks nice.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • P Offline
        P Offline
        profuma
        wrote on last edited by
        #3

        Seems to make sense now. The 'dial control' code shows the x position has been multiplied by a factor of 100, so to offset that dial code has been scaled down by roughly 100 but the dial has value up 0 to 120 - so they are off by 20 degree ? To offset slider which is 34 px in width, 30 px has been subtracted from slider container width. Why would they complicate the code unnecessarily is beyond me.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          I do not know the example. I just reasoned backwards from the chunk of code you posted.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          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