• 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.


  • Qt Champions 2017

    @MScottM said in Photorealism:

    photorealistic gauges

    But what would be considered one ?
    alt text

  • Qt Champions 2017

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

  • 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!


  • Qt Champions 2017

    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.

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


    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
    //    gaugeWindow();
    //    void timerEvent(QTimerEvent *);
    //    void render(QPainter *painter);
    //    int m_timerId;
    //gaugeWindow::gaugeWindow() {
    //    m_timerId = startTimer(1000);
    //void gaugeWindow::timerEvent() {
    //    if (event->timerId() == m_timerId)
    //        renderLater();
    MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::MainWindow)
        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.translate(151, 146); //center
        painter.rotate(angle); //degrees
        painter.drawConvexPolygon(needle, 3);
    //int MainWindow::updateAngle(int angle)
    //        int newAngle = -90;
    //        for (int i=0; i<180; i++) {
    //            newAngle += 1;
    //        }
    //        return angle;
        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...


  • Qt Champions 2017

    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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.