/QT-Gauge-Speedometer

Speedometer and Gauge for Qt QWidget and QMainWindows

Primary LanguageC++GNU General Public License v3.0GPL-3.0

QT-Gauge---Speedometer

Speedometer and Gauge for Qt QWidget and QMainWindows

This is a graphical gauage for qt/c++ application you can use it in your application easily

In This gauge we don't use any picture or wallpaper , we making it on C++ Runtime by drawing

I just Show How to Create Gauge by this class But you can make other thing like Compass , AttitudeMeter , ...

How To use This gauge
  • First use header and source file in your project
  • After That add vertical layout to your ui file
  • In the End Use This code To Start
Add This to header (.h) file
 #include "qcgaugewidget.h"
 QcGaugeWidget * mSpeedGauge;
 QcNeedleItem *mSpeedNeedle;
Add This to Source (.cpp) file
    mSpeedGauge = new QcGaugeWidget;
    mSpeedGauge->addBackground(99);
    //this will add side color to gauge
    QcBackgroundItem *bkg1 = mSpeedGauge->addBackground(92);
    bkg1->clearrColors();
    bkg1->addColor(0.1,Qt::black);
    bkg1->addColor(1.0,Qt::white);
    QcBackgroundItem *bkg2 = mSpeedGauge->addBackground(88);
    bkg2->clearrColors();
    //this two line below will set background color of gauge
    bkg2->addColor(0.1,Qt::gray);
    bkg2->addColor(1.0,Qt::darkGray);
    mSpeedGauge->addArc(55);
    mSpeedGauge->addDegrees(65)->setValueRange(0,120);
    //this will add color red-green color band
    mSpeedGauge->addColorBand(50);
    // add value rage
    mSpeedGauge->addValues(80)->setValueRange(0, 80);
    //set gauge title
    mSpeedGauge->addLabel(70)->setText("Km/h");
    QcLabelItem *lab = mSpeedGauge->addLabel(40);
    lab->setText("0");
    mSpeedNeedle = mSpeedGauge->addNeedle(60);
    //add lable 
    mSpeedNeedle->setLabel(lab);
    // set needle color 
    mSpeedNeedle->setColor(Qt::white);
    //add range for your gauge => it should be just like the gauge range 
    mSpeedNeedle->setValueRange(0,80);
    mSpeedGauge->addBackground(7);
    //add some shadow like glass
    mSpeedGauge->addGlass(88);
    //add this to your vertical layout
    ui->verticalLayout->addWidget(mSpeedGauge);
Credit and Thanks

This project Base is https://github.com/Berrima/Qt-custom-gauge-widget