Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
percent_bar_widget.h
Go to the documentation of this file.
1
7
8#ifndef PERCENT_BAR_WIDGET_H
9#define PERCENT_BAR_WIDGET_H
10
11#include <QWidget>
12#include <QtGlobal>
13#include <qtmetamacros.h>
14
15class PercentBarWidget : public QWidget
16{
17 Q_OBJECT
18
19public:
20 explicit PercentBarWidget(QWidget *parent, double initialValue);
21
22 void setValue(double newValue)
23 {
24 valueToDisplay = qBound(-100.0, newValue, 100.0); // Clamp to [-100, 100]
25 update(); // Trigger repaint
26 }
27
28 double value() const
29 {
30 return valueToDisplay;
31 }
32
33protected:
34 void paintEvent(QPaintEvent *event) override;
35
36private:
37 double valueToDisplay; // Ranges from -100 to 100
38};
39
40#endif // PERCENT_BAR_WIDGET_H
PercentBarWidget(QWidget *parent, double initialValue)
Definition percent_bar_widget.cpp:11
double value() const
Definition percent_bar_widget.h:28
double valueToDisplay
Definition percent_bar_widget.h:37
void setValue(double newValue)
Definition percent_bar_widget.h:22
void paintEvent(QPaintEvent *event) override
Definition percent_bar_widget.cpp:16