CCIMXDesktop
 
Loading...
Searching...
No Matches
GaugeWidget Class Reference

A customizable gauge widget for displaying numeric values. More...

#include <GaugeWidget.h>

Inheritance diagram for GaugeWidget:

Signals

void valueChanged (double value)
 Signal emitted when the gauge value changes.
 
void valueChanged (double value)
 Signal emitted when the gauge value changes.
 

Public Member Functions

 GaugeWidget (QWidget *parent=nullptr)
 Constructor.
 
void setRange (int min, int max)
 Set the gauge range.
 
void setTitle (const QString &title)
 Set the title text displayed on the gauge.
 
void setUnit (const QString &unit)
 Set the unit text displayed with the value.
 
double value () const
 Get the current gauge value.
 
void update_value (const double value)
 Update the gauge value with optional animation.
 
 GaugeWidget (QWidget *parent=nullptr)
 Constructor.
 
void setRange (int min, int max)
 Set the gauge range.
 
void setTitle (const QString &title)
 Set the title text displayed on the gauge.
 
void setUnit (const QString &unit)
 Set the unit text displayed with the value.
 
double value () const
 Get the current gauge value.
 
void update_value (const double value)
 Update the gauge value with optional animation.
 

Static Public Attributes

static constexpr int DEF_MIN_VALUE { 0 }
 Default minimum value of the gauge.
 
static constexpr int DEF_MAX_VALUE { 100 }
 Default maximum value of the gauge.
 
static constexpr short TITLE_FONT_SZ { 12 }
 Font size for the title text.
 
static constexpr short CURVAL_FOUT_SZ { 10 }
 Font size for the current value text.
 
static constexpr int ANIMATION_DURATION { 500 }
 Duration of animation in milliseconds.
 
static constexpr float WIDGET_MIN_WIDTH { 200 }
 Minimum widget width.
 
static constexpr float WIDGET_MIN_HEIGHT { 200 }
 Minimum widget height.
 
static constexpr QColor BOARD_COLOR = QColor(160, 160, 160)
 Base color for the gauge board.
 
static constexpr QColor FROM_BOARD_COLOR = QColor(190, 190, 190)
 Gradient start color for board.
 
static constexpr QColor TO_BOARD_COLOR = QColor(110, 110, 110)
 Gradient end color for board.
 
static constexpr short BOARD_LEN = 1
 Width of the board outline.
 
static constexpr short START_ANGLE { 225 }
 Start angle for gauge drawing (degrees)
 
static constexpr short TOTAL_ANGLE { 270 }
 Total sweep angle of gauge arc (degrees)
 
static constexpr short COLOR_GRAD_WIDTH { 8 }
 Width of the color gradient arc.
 
static constexpr short COLOR_RADIUS { 90 }
 Radius for the gradient arc.
 
static constexpr QColor START_COLOR = QColor(255, 0, 0)
 Gradient start color for the gauge arc.
 
static constexpr QColor END_COLOR = QColor(0, 255, 0)
 Gradient end color for the gauge arc.
 
static constexpr int TICK_CNT { 55 }
 Total number of ticks on the gauge.
 
static constexpr short MAIN_TICK_WIDTH { 2 }
 Width of main ticks.
 
static constexpr short SUB_TICK_WIDTH { 1 }
 Width of sub ticks.
 
static constexpr short MAIN_TICK_LENGTH { 8 }
 Length of main ticks.
 
static constexpr short SUB_TICK_LENGTH { 5 }
 Length of sub ticks.
 
static constexpr short SUB_MAIN_RATE { 5 }
 Number of sub ticks per main tick.
 
static constexpr QColor TICK_COLOR = QColor(255, 255, 255)
 Color of the ticks.
 
static constexpr short LABEL_FONT_SZ { 6 }
 Font size for labels on ticks.
 
static constexpr QColor LABEL_COLOR = QColor(255, 255, 255)
 Color for labels.
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 Paint event handler to render the gauge.
 
void paintEvent (QPaintEvent *event) override
 Paint event handler to render the gauge.
 

Properties

double value
 property object
 

Detailed Description

A customizable gauge widget for displaying numeric values.

This widget provides a circular gauge with configurable range, title, unit, and smooth animated value updates. It supports drawing ticks, labels, needle, and gradient arcs.

Constructor & Destructor Documentation

◆ GaugeWidget() [1/2]

GaugeWidget::GaugeWidget ( QWidget *  parent = nullptr)
explicit

Constructor.

Parameters
parentParent widget pointer.

◆ GaugeWidget() [2/2]

GaugeWidget::GaugeWidget ( QWidget *  parent = nullptr)
explicit

Constructor.

Parameters
parentParent widget pointer.

Member Function Documentation

◆ paintEvent() [1/2]

void GaugeWidget::paintEvent ( QPaintEvent *  event)
overrideprotected

Paint event handler to render the gauge.

Parameters
eventPaint event.

◆ paintEvent() [2/2]

void GaugeWidget::paintEvent ( QPaintEvent *  event)
overrideprotected

Paint event handler to render the gauge.

Parameters
eventPaint event.

◆ setRange() [1/2]

void GaugeWidget::setRange ( int  min,
int  max 
)
inline

Set the gauge range.

Parameters
minMinimum value.
maxMaximum value.

◆ setRange() [2/2]

void GaugeWidget::setRange ( int  min,
int  max 
)
inline

Set the gauge range.

Parameters
minMinimum value.
maxMaximum value.

◆ setTitle() [1/2]

void GaugeWidget::setTitle ( const QString &  title)
inline

Set the title text displayed on the gauge.

Parameters
titleGauge title.

◆ setTitle() [2/2]

void GaugeWidget::setTitle ( const QString &  title)
inline

Set the title text displayed on the gauge.

Parameters
titleGauge title.

◆ setUnit() [1/2]

void GaugeWidget::setUnit ( const QString &  unit)
inline

Set the unit text displayed with the value.

Parameters
unitUnit string.

◆ setUnit() [2/2]

void GaugeWidget::setUnit ( const QString &  unit)
inline

Set the unit text displayed with the value.

Parameters
unitUnit string.

◆ update_value() [1/2]

void GaugeWidget::update_value ( const double  value)

Update the gauge value with optional animation.

Parameters
valueNew value to display.

◆ update_value() [2/2]

void GaugeWidget::update_value ( const double  value)

Update the gauge value with optional animation.

Parameters
valueNew value to display.

◆ value() [1/2]

double GaugeWidget::value ( ) const
inline

Get the current gauge value.

Returns
Current value.

◆ value() [2/2]

double GaugeWidget::value ( ) const
inline

Get the current gauge value.

Returns
Current value.

◆ valueChanged [1/2]

void GaugeWidget::valueChanged ( double  value)
signal

Signal emitted when the gauge value changes.

Parameters
valueThe new value.

◆ valueChanged [2/2]

void GaugeWidget::valueChanged ( double  value)
signal

Signal emitted when the gauge value changes.

Parameters
valueThe new value.

Property Documentation

◆ value

double GaugeWidget::value
readwrite

property object

Parameters
valueChanged

The documentation for this class was generated from the following files: