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. Photorealism
Qt 6.11 is out! See what's new in the release blog

Photorealism

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 3.3k 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
    MScottM
    wrote on last edited by
    #1

    I'm interested in creating photorealistic gauges for a dashboard. I've searched around and haven't (yet) seen this being done with QT. I'm guessing it isn't as simple as animating a needle over an image of a gauge to create a 'realistic' looking one? Not sure how I would even start!

    I would appreciate hearing thoughts on how this might be possible, or pointers to where it has already been done.

    Thanks!

    aha_1980A 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      @MScottM said in Photorealism:

      photorealistic gauges

      But what would be considered one ?
      alt text

      1 Reply Last reply
      3
      • M MScottM

        I'm interested in creating photorealistic gauges for a dashboard. I've searched around and haven't (yet) seen this being done with QT. I'm guessing it isn't as simple as animating a needle over an image of a gauge to create a 'realistic' looking one? Not sure how I would even start!

        I would appreciate hearing thoughts on how this might be possible, or pointers to where it has already been done.

        Thanks!

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @MScottM e.g. here you have a real world Qt example.

        Qt has to stay free or it will die.

        1 Reply Last reply
        2
        • M Offline
          M Offline
          MScottM
          wrote on last edited by
          #4

          Thanks for the replies.

          By photo-realistic what I mean is, the gauge looks like it could be, say, the tachometer out of a Ferrari Dino, because it is an actual photo of a Dino tachometer (*.png, or *.jpg for example), only the pointer responds to input from software. I think I've seen this done in a flight simulator a while back, but I can't remember which.

          @aha_1980 I appreciate the link to the QT dashboard, its very interesting, but it isn't quite what I mean. those gauges are drawn programmatically, like from the gauge library. I hope I'm describing the distinction I'm trying for clearly enough!

          -Scott

          1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi
            It really depend on the photos how you
            would paint the pointer as to look good.
            If you are skilled with 3D software, its possible to render a really
            authentic look version.

            1 Reply Last reply
            2
            • M Offline
              M Offline
              MScottM
              wrote on last edited by
              #6

              Okay - I managed to put a needle onto a photo of a gauge that I downloaded and photo-edited the original needle out of:

              Original:
              0_1519603427765_RPM_Gauge.PNG

              Mine:
              0_1519603457239_RPM_My Pointer.PNG

              Here is the code I kluged together:

              #include "mainwindow.h"
              #include "ui_mainwindow.h"
              #include "QBitmap"
              #include "QPainter"
              #include "QTime"
              #include <QtGui>
              //#include "rasterwindow.h"
              
              /*class gaugeWindow
              //{
              //public:
              //    gaugeWindow();
              
              //protected:
              //    void timerEvent(QTimerEvent *);
              //    void render(QPainter *painter);
              
              //private:
              //    int m_timerId;
              //};
              
              //gaugeWindow::gaugeWindow() {
              //    m_timerId = startTimer(1000);
              //}
              
              //void gaugeWindow::timerEvent() {
              //    if (event->timerId() == m_timerId)
              //        renderLater();
              //}
              */
              
              MainWindow::MainWindow(QWidget *parent) :
                  QMainWindow(parent),
                  ui(new Ui::MainWindow)
              {
                  ui->setupUi(this);
              
                  static const QPoint needle[3] = {
                          QPoint(7, 8),
                          QPoint(-7, 8),
                          QPoint(0, -70)
                      };
                  QColor needleColor(0, 0, 0);
              
                  //QLabel lblRpm;
                  QPixmap pixmap("C:\\Users\\scott\\Documents\\Qt\\Gauge_Test\\RPM_Gauge_no_needle.png");
                  QPainter painter(&pixmap);
                  //painter.setPen(needleColor);
              
                  painter.setRenderHint(QPainter::Antialiasing);
                  painter.translate(151, 146); //center
                  painter.setPen(Qt::NoPen);
                  painter.setBrush(needleColor);
              
                  painter.save();
                  painter.rotate(angle); //degrees
                  painter.drawConvexPolygon(needle, 3);
                  painter.restore();
              
                  ui->lblRpm->setPixmap(pixmap);
                  ui->lblRpm->setMask(pixmap.mask());
                  ui->lblRpm->show();
              }
              
              //int MainWindow::updateAngle(int angle)
              //{
              //        int newAngle = -90;
              //        for (int i=0; i<180; i++) {
              //            newAngle += 1;
              //        }
              //        return angle;
              //}
              
              MainWindow::~MainWindow()
              {
                  delete ui;
              }
              

              Now I'm trying to figure out how to attach the needle to something that will let me update it on the fly for demonstration, like a timer, or a slider. I would appreciate if someone could give me a pointer (HA!) towards some way to make that work...

              Thanks!!

              1 Reply Last reply
              1
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi
                Looking good.
                Convert it to a custom widget, give it a setSpeed slot and
                hook slot up to a timer to make it do something.

                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