Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. About algorithm render tachometer gauge on embedded catalog example and demo
Qt 6.11 is out! See what's new in the release blog

About algorithm render tachometer gauge on embedded catalog example and demo

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 3.5k 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.
  • B Offline
    B Offline
    banlinhtienphong
    wrote on last edited by
    #1

    I read source code in file qtsvgdialgauge.cpp and qtsvgdialgauge.h and in method QtSvgDialGauge::paintEvent I don't understand code lines:
    @void QtSvgDialGauge::setNeedleOrigin(qreal x, qreal y)
    {
    m_originX = qMin(static_cast<qreal>(1.0), qMax(static_cast<qreal>(0.0), x));
    m_originY = qMin(static_cast<qreal>(1.0), qMax(static_cast<qreal>(0.0), y));
    }@
    what is needle origin ,....
    @// Tachometer
    QtSvgDialGauge *gauge = new QtSvgDialGauge(group);
    gauge->setSkin("Tachometer");
    gauge->setNeedleOrigin(0.486, 0.466);@
    why is 0.486 and 0.466
    please help me understand this. Thank in advance!

    [edit : Please use code tags (@ before and after your code) , Eddy]

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

      @
      void QtSvgDialGauge::setNeedleOrigin(qreal x, qreal y)
      {
      // make sure x is between 0 and 1
      m_originX = qMin( // originX = the smaller value of
      static_cast<qreal>(1.0), // 1 and
      qMax( // the bigger value of
      static_cast<qreal>(0.0), // 0 and
      x)); // x

      // make sure y is between 0 and 1
      m_originY = qMin(static_cast<qreal>(1.0), qMax(static_cast<qreal>(0.0), y));
      

      }@

      [quote]
      @// Tachometer
      QtSvgDialGauge *gauge = new QtSvgDialGauge(group);
      gauge->setSkin("Tachometer");
      gauge->setNeedleOrigin(0.486, 0.466);
      @

      why is 0.486 and 0.466
      [/quote]
      It probably looks best...

      "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
      • B Offline
        B Offline
        banlinhtienphong
        wrote on last edited by
        #3

        I still don't understand why make sure y is between 0 and 1?
        I think 0.486 and 0.466 not "it probably looks best..."
        anyone can explain for me?

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

          [quote author="banlinhtienphong" date="1316958365"]I still don't understand why make sure y is between 0 and 1?[/quote] I assume the coordinates need to be defined within the square (0.0,0.0)-(1.0,1.0). If that's the case, they're making sure the needle origin is within sight.

          [quote author="banlinhtienphong" date="1316958365"]
          I think 0.486 and 0.466 not "it probably looks best..."
          anyone can explain for me?[/quote]What don't you understand? Do you not understand why the needle origin is just a tad off-center (so not (0.5, 0.5))? Do you not understand what the needle origin is to begin with?

          It seems you're a non-native English speaker, and I understand that can make it harder to write, but please try to state what exactly you're having trouble with.

          "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