Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform 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 <QPainter>
12#include <QWidget>
13
14class PercentBarWidget : public QWidget
15{
16 Q_OBJECT
17
18public:
19 explicit PercentBarWidget(QWidget *parent, double initialValue);
20
21 void setValue(double newValue)
22 {
23 valueToDisplay = qBound(-100.0, newValue, 100.0); // Clamp to [-100, 100]
24 update(); // Trigger repaint
25 }
26
27 double value() const
28 {
29 return valueToDisplay;
30 }
31
32protected:
33 void paintEvent(QPaintEvent *event) override;
34
35private:
36 double valueToDisplay; // Ranges from -100 to 100
37};
38
39#endif // PERCENT_BAR_WIDGET_H
PercentBarWidget(QWidget *parent, double initialValue)
Definition percent_bar_widget.cpp:3
double value() const
Definition percent_bar_widget.h:27
double valueToDisplay
Definition percent_bar_widget.h:36
void setValue(double newValue)
Definition percent_bar_widget.h:21
void paintEvent(QPaintEvent *event) override
Definition percent_bar_widget.cpp:8