# QT-Gauge-Speedometer仪表控件2 **Repository Path**: 0755/qt-gauge-speedometer-2 ## Basic Information - **Project Name**: QT-Gauge-Speedometer仪表控件2 - **Description**: No description available - **Primary Language**: C++ - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 4 - **Created**: 2021-02-14 - **Last Updated**: 2023-08-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 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
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