Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Speedometer Needle
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Speedometer Needle

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.7k 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.
  • M Offline
    M Offline
    maxg0
    wrote on last edited by
    #1

    Hi All,

    I am new to Qt and facing the following issue. I have been given a background image of a tachometer/speedometer which I can load onto my Main Window widget.
    Now I would simply like to add a Needle to this device right in the middle, which would be a dynamical object able to respond to updates. Is there any Widget which would allow me to achieve this?
    We cannot use QML. We need to obtain this result by using a widget class.
    In case a predefined QNeedle does not exist, How would I start creating such a graphical object?

    Many Thanks for your help

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      there is no widget available which does what you want out of the box.

      You can subclass QWidget and overrride it's paintEvent() handler and do all the drawing in there.
      E.g. draw the background image first and then the needle by yourself. You can use all the capabilities of the QPainter class for drawing.

      Or you just go with the QGraphicsView approach and add the background image and also the needle (as image) as QGraphicsPixmapItems and just rotate the needle-item accordingly.

      Edit:
      Alternatively you can also use one of "Qwt's widgets":http://qwt.sourceforge.net/controlscreenshots.html.
      Or check the source code of their implementation...

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JulienMaille
        wrote on last edited by
        #3

        A while ago Nokia showcased some nice gauge widgets:
        http://basyskom.com/news/143-demos-qt5-port.html

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maxg0
          wrote on last edited by
          #4

          Hi raven-worx,

          For now your first solution of subclassing QWidget and overriding paintEvent() seems to work. Hopefully it won't take too much work to paint a reasonable dial or gauge control. Qwt's widgets look quite tempting though.

          Cheers

          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