Skip to content

Commit ab59535

Browse files
committed
Github Issue #218: Experimenting with the widget
1 parent a12c882 commit ab59535

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

togglebutton.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "togglebutton.h"
2+
#include <QPainter>
23

34
ToggleButton::ToggleButton(QWidget *parent):QAbstractButton(parent), animation(new QPropertyAnimation(this,"pos",this))
45
{
@@ -32,5 +33,9 @@ void ToggleButton::mouseReleaseEvent(QMouseEvent *e)
3233

3334
void ToggleButton::paintEvent(QPaintEvent *e)
3435
{
36+
QPainter p(this);
37+
p.setBrush(state? brush:Qt::gray);
38+
p.setRenderHint(QPainter::Antialiasing, true);
39+
p.drawRoundedRect(QRect(3,3,width()-2* 3, height()-2*3), 7.0,7.0);
3540

3641
}

togglebutton.h

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class ToggleButton : public QAbstractButton
1111
private:
1212
bool state;
1313
QPropertyAnimation *animation = nullptr;
14+
1415
QBrush track, circle, brush;
1516
public:
1617
ToggleButton(QWidget * parent);

0 commit comments

Comments
 (0)