CANdevStudio
Development tool for CAN bus simulation
Loading...
Searching...
No Matches
nlmpushbutton.h
Go to the documentation of this file.
1#ifndef NLMPUSHBUTTON_H
2#define NLMPUSHBUTTON_H
3
4#include <QPushButton>
6
8
10 : qPushButton(new QPushButton)
11 {
12 qPushButton->setProperty("type", "nlmItem");
13 }
14
15 void pressedCbk(const pressed_t& cb) override
16 {
17 QObject::connect(qPushButton, &QPushButton::pressed, cb);
18 }
19
20 QWidget* mainWidget() override
21 {
22 return qPushButton;
23 }
24
25 void init(const QString& buttonName, bool isEnable) override
26 {
27 qPushButton->setText(buttonName);
28 qPushButton->setFlat(true);
29 setDisabled(!isEnable);
30 }
31
32 void setDisabled(bool state) override
33 {
34 qPushButton->setDisabled(state);
35 }
36
37 bool isEnabled() override
38 {
39 return qPushButton->isEnabled();
40 }
41
42 void setCheckable(bool checked) override
43 {
44 qPushButton->setCheckable(checked);
45 }
46
47 bool checkable() override
48 {
49 return qPushButton->isCheckable();
50 }
51
52 bool checked() override
53 {
54 return qPushButton->isChecked();
55 }
56
57 void setChecked(bool checked) override
58 {
59 if(checked != qPushButton->isChecked()) {
60 qPushButton->animateClick();
61 }
62 }
63
64
65private:
66 QPushButton* qPushButton;
67};
68#endif // NLMPUSHBUTTON_H
Definition nlmpushbutton.h:7
void init(const QString &buttonName, bool isEnable) override
Definition nlmpushbutton.h:25
NLMPushButton()
Definition nlmpushbutton.h:9
void setDisabled(bool state) override
Definition nlmpushbutton.h:32
bool isEnabled() override
Definition nlmpushbutton.h:37
bool checked() override
Definition nlmpushbutton.h:52
void setChecked(bool checked) override
Definition nlmpushbutton.h:57
bool checkable() override
Definition nlmpushbutton.h:47
QWidget * mainWidget() override
Definition nlmpushbutton.h:20
void setCheckable(bool checked) override
Definition nlmpushbutton.h:42
void pressedCbk(const pressed_t &cb) override
Definition nlmpushbutton.h:15
Definition pushbuttoninterface.h:8
std::function< void()> pressed_t
Definition pushbuttoninterface.h:13