QRoundProgressBar
#include <QRoundProgressBar.h>
Public Types | |
enum | BarStyle { StyleDonut , StylePie , StyleLine } |
Public Types inherited from QWidget | |
enum | RenderFlag |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric |
Public Slots | |
void | setMaximum (double max) |
void | setMinimum (double min) |
void | setRange (double min, double max) |
void | setValue (double val) |
void | setValue (int val) |
Static Public Attributes | |
static const int | PositionBottom = -90 |
static const int | PositionLeft = 180 |
static const int | PositionRight = 0 |
static const int | PositionTop = 90 |
Protected Attributes | |
BarStyle | m_barStyle |
double | m_dataPenWidth |
int | m_decimals |
QString | m_format |
QGradientStops | m_gradientData |
double | m_max |
double | m_min |
double | m_nullPosition |
double | m_outlinePenWidth |
bool | m_rebuildBrush |
int | m_updateFlags |
double | m_value |
Static Protected Attributes | |
static const int | UF_MAX = 4 |
static const int | UF_PERCENT = 2 |
static const int | UF_VALUE = 1 |
Detailed Description
The QRoundProgressBar class represents a circular progress bar and maintains its API similar to the QProgressBar.
Styles
QRoundProgressBar currently supports Donut, Pie and Line styles. See setBarStyle() for more details.
Colors
Generally QRoundProgressBar uses its palette and font attributes to define how it will look.
The following QPalette members are considered:
- QPalette::Window background of the whole widget (normally should be set to Qt::NoBrush)
- QPalette::Base background of the non-filled progress bar area (should be set to Qt::NoBrush to make it transparent)
- QPalette::AlternateBase background of the central circle where the text is shown (for Donut style)
- QPalette::Shadow foreground of the non-filled progress bar area (i.e. border color)
- QPalette::Highlight background of the filled progress bar area
- QPalette::Text color of the text shown in the center
Create a QPalette with given attributes and apply it via setPalette()
.
Color gradient
Donut and Pie styles allow to use color gradient for currernt value area instead of plain brush fill. See setDataColors() for more details.
Value text
Value text is generally drawn inside the QRoundProgressBar using its font()
and QPalette::Text role from its palette()
.
To define pattern of the text, use setFormat() function (see Qt's QProgressBar for more details).
To define number of decimals to be shown, use setDecimals() function.
Font
To use own font for value text, apply it via setFont()
.
By default, font size will be adjusted automatically to fit the inner circle of the widget.
Definition at line 60 of file QRoundProgressBar.h.
Member Enumeration Documentation
◆ BarStyle
The BarStyle enum defines general look of the progress bar.
Enumerator | |
---|---|
StyleDonut | Donut style (filled torus around the text) |
StylePie | Pie style (filled pie segment with the text in center) |
StyleLine | Line style (thin round line around the text) |
Definition at line 86 of file QRoundProgressBar.h.
Constructor & Destructor Documentation
◆ QRoundProgressBar()
Definition at line 24 of file QRoundProgressBar.cpp.
Member Function Documentation
◆ barStyle()
|
inline |
Returns current progree bar style.
- See also
- setBarStyle
Definition at line 104 of file QRoundProgressBar.h.
◆ calculateInnerRect()
|
protectedvirtual |
Definition at line 284 of file QRoundProgressBar.cpp.
◆ dataPenWidth()
|
inline |
Returns width of the data circle pen.
Definition at line 124 of file QRoundProgressBar.h.
◆ decimals()
|
inline |
Returns number of decimals to show after the comma (default is 1).
- See also
- setFormat, setDecimals
Definition at line 164 of file QRoundProgressBar.h.
◆ drawBackground()
Definition at line 221 of file QRoundProgressBar.cpp.
◆ drawBase()
Definition at line 226 of file QRoundProgressBar.cpp.
◆ drawInnerBackground()
|
protectedvirtual |
Definition at line 301 of file QRoundProgressBar.cpp.
◆ drawText()
|
protectedvirtual |
Definition at line 310 of file QRoundProgressBar.cpp.
◆ drawValue()
|
protectedvirtual |
Definition at line 253 of file QRoundProgressBar.cpp.
◆ format()
|
inline |
Returns the string used to generate the current text.
Definition at line 153 of file QRoundProgressBar.h.
◆ hasHeightForWidth()
|
inlineoverrideprotectedvirtual |
Reimplemented from QWidget.
Definition at line 228 of file QRoundProgressBar.h.
◆ heightForWidth()
|
inlineoverrideprotectedvirtual |
Reimplemented from QWidget.
Definition at line 229 of file QRoundProgressBar.h.
◆ maximum()
|
inline |
Returns maximum of the allowed value range.
- See also
- setMaximum, setRange
Definition at line 180 of file QRoundProgressBar.h.
◆ minimum()
|
inline |
Returns minimum of the allowed value range.
- See also
- setMinimum, setRange
Definition at line 175 of file QRoundProgressBar.h.
◆ minimumSizeHint()
|
inlineoverrideprotectedvirtual |
Reimplemented from QWidget.
Definition at line 226 of file QRoundProgressBar.h.
◆ nullPosition()
|
inline |
Return position (in degrees) of minimum value.
- See also
- setNullPosition
Definition at line 75 of file QRoundProgressBar.h.
◆ outlinePenWidth()
|
inline |
Returns width of the outline circle pen.
Definition at line 114 of file QRoundProgressBar.h.
◆ paintEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget.
Definition at line 160 of file QRoundProgressBar.cpp.
◆ rebuildDataBrushIfNeeded()
|
protected |
Definition at line 360 of file QRoundProgressBar.cpp.
◆ resetFormat()
void QRoundProgressBar::resetFormat | ( | ) |
Sets format string to empty string.
No text will be shown therefore. See setFormat() for more information.
Definition at line 144 of file QRoundProgressBar.cpp.
◆ setBarStyle()
void QRoundProgressBar::setBarStyle | ( | QRoundProgressBar::BarStyle | style | ) |
Sets visual style of the widget.
- See also
- barStyle
Definition at line 93 of file QRoundProgressBar.cpp.
◆ setDataColors()
void QRoundProgressBar::setDataColors | ( | const QGradientStops & | stopPoints | ) |
Sets colors of the visible data and makes gradient brush from them.
Gradient colors can be set for Donut and Pie styles (see setBarStyle() function).
Warning: this function will override widget's palette()
to set dynamically created gradient brush.
- Parameters
-
stopPoints List of colors (should have at least 2 values, see Qt's QGradientStops for more details). Color value at point 0 corresponds to the minimum() value, while color value at point 1 corresponds to the maximum(). Other colors will be distributed accordingly to the defined ranges (see setRange()).
Definition at line 123 of file QRoundProgressBar.cpp.
◆ setDataPenWidth()
void QRoundProgressBar::setDataPenWidth | ( | double | penWidth | ) |
Sets width of the data circle pen.
- Parameters
-
penWidth width of the data circle pen (in pixels)
Definition at line 113 of file QRoundProgressBar.cpp.
◆ setDecimals()
void QRoundProgressBar::setDecimals | ( | int | count | ) |
Sets number of decimals to show after the comma (default is 1).
- See also
- setFormat
Definition at line 150 of file QRoundProgressBar.cpp.
◆ setFormat()
Defines the string used to generate the current text.
If no format is set, no text will be shown.
- Parameters
-
format see QProgressBar's format description
- See also
- setDecimals
Definition at line 134 of file QRoundProgressBar.cpp.
◆ setMaximum
|
slot |
Defines maximum of the allowed value range.
If the current value does not fit into the range, it will be automatically adjusted.
- Parameters
-
max maximum of the allowed value range
- See also
- setRange
Definition at line 55 of file QRoundProgressBar.cpp.
◆ setMinimum
|
slot |
Defines minimum of the allowed value range.
If the current value does not fit into the range, it will be automatically adjusted.
- Parameters
-
min minimum of the allowed value range
- See also
- setRange
Definition at line 50 of file QRoundProgressBar.cpp.
◆ setNullPosition()
void QRoundProgressBar::setNullPosition | ( | double | position | ) |
Defines position of minimum value.
- Parameters
-
position position on the circle (in degrees) of minimum value
- See also
- nullPosition
Definition at line 80 of file QRoundProgressBar.cpp.
◆ setOutlinePenWidth()
void QRoundProgressBar::setOutlinePenWidth | ( | double | penWidth | ) |
Sets width of the outline circle pen.
- Parameters
-
penWidth width of the outline circle pen (in pixels)
Definition at line 103 of file QRoundProgressBar.cpp.
◆ setRange
|
slot |
Defines minimum und maximum of the allowed value range.
If the current value does not fit into the range, it will be automatically adjusted.
- Parameters
-
min minimum of the allowed value range max maximum of the allowed value range
Definition at line 31 of file QRoundProgressBar.cpp.
◆ setValue [1/2]
|
slot |
Sets a value which will be shown on the widget.
Definition at line 60 of file QRoundProgressBar.cpp.
◆ setValue [2/2]
|
slot |
Integer version of the previous slot.
Definition at line 75 of file QRoundProgressBar.cpp.
◆ value()
|
inline |
Returns current value shown on the widget.
- See also
- setValue()
Definition at line 170 of file QRoundProgressBar.h.
◆ valueFormatChanged()
|
protectedvirtual |
Definition at line 344 of file QRoundProgressBar.cpp.
◆ valueToText()
|
protectedvirtual |
Definition at line 325 of file QRoundProgressBar.cpp.
Member Data Documentation
◆ m_barStyle
|
protected |
Definition at line 237 of file QRoundProgressBar.h.
◆ m_dataPenWidth
|
protected |
Definition at line 238 of file QRoundProgressBar.h.
◆ m_decimals
|
protected |
Definition at line 244 of file QRoundProgressBar.h.
◆ m_format
|
protected |
Definition at line 243 of file QRoundProgressBar.h.
◆ m_gradientData
|
protected |
Definition at line 240 of file QRoundProgressBar.h.
◆ m_max
|
protected |
Definition at line 233 of file QRoundProgressBar.h.
◆ m_min
|
protected |
Definition at line 233 of file QRoundProgressBar.h.
◆ m_nullPosition
|
protected |
Definition at line 236 of file QRoundProgressBar.h.
◆ m_outlinePenWidth
|
protected |
Definition at line 238 of file QRoundProgressBar.h.
◆ m_rebuildBrush
|
protected |
Definition at line 241 of file QRoundProgressBar.h.
◆ m_updateFlags
|
protected |
Definition at line 249 of file QRoundProgressBar.h.
◆ m_value
|
protected |
Definition at line 234 of file QRoundProgressBar.h.
◆ PositionBottom
|
static |
Definition at line 69 of file QRoundProgressBar.h.
◆ PositionLeft
|
static |
Definition at line 66 of file QRoundProgressBar.h.
◆ PositionRight
|
static |
Definition at line 68 of file QRoundProgressBar.h.
◆ PositionTop
|
static |
Definition at line 67 of file QRoundProgressBar.h.
◆ UF_MAX
|
staticprotected |
Definition at line 248 of file QRoundProgressBar.h.
◆ UF_PERCENT
|
staticprotected |
Definition at line 247 of file QRoundProgressBar.h.
◆ UF_VALUE
|
staticprotected |
Definition at line 246 of file QRoundProgressBar.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:05 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.