Code Monkey home page Code Monkey logo

qt-gauge-speedometer's Introduction

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

qt-gauge-speedometer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

qt-gauge-speedometer's Issues

Member variable not initialized

Dear NimaMX,

Member variable "mBandStartValue" of class "QcColorBand" is not initialized.
When I tried to use multiple gauges (more than 2) at the same time, the color band shows randomly. Adding "mBandStartValue = 0;" in constructor has solved the bug.

Sincerely,
Eddie

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.