CANdevStudio
Development tool for CAN bus simulation
Loading...
Searching...
No Matches
nlmcheckbox.h
Go to the documentation of this file.
1#ifndef NLMCHECKBOX_H
2#define NLMCHECKBOX_H
3
4#include <QCheckBox>
5#include <QHBoxLayout>
6#include <QLineEdit>
8
10
12 : qWidget(new QWidget)
13 , qCheckBox(new QCheckBox)
14 , qLayout(nullptr)
15 {
16 init();
17 qCheckBox->setProperty("type", "nlmItem");
18 }
19
20 void toggledCbk(const toggled_t& cb) override
21 {
22 QObject::connect(qCheckBox, &QCheckBox::toggled, cb);
23 }
24
25 QWidget* mainWidget() override
26 {
27 return qWidget;
28 }
29
30 bool getState() override
31 {
32 return qCheckBox->isChecked();
33 }
34
35 void init()
36 {
37 qLayout = new QHBoxLayout(qWidget);
38 qLayout->addWidget(qCheckBox);
39 qLayout->setAlignment(Qt::AlignCenter);
40 qLayout->setContentsMargins(0, 0, 0, 0);
41 qWidget->setLayout(qLayout);
42 }
43
44 void setState(bool state) override
45 {
46 if (qCheckBox->isChecked() != state) {
47 qCheckBox->setChecked(state);
48 emit qCheckBox->released();
49 }
50 }
51
52 void setDisabled(bool state) override
53 {
54 qCheckBox->setDisabled(state);
55 }
56
57
58private:
59 QWidget* qWidget;
60 QCheckBox* qCheckBox;
61 QHBoxLayout* qLayout;
62};
63
64#endif // NLMCHECKBOX_H
Definition checkboxinterface.h:7
std::function< void(bool)> toggled_t
Definition checkboxinterface.h:12
Definition nlmcheckbox.h:9
NLMCheckBox()
Definition nlmcheckbox.h:11
bool getState() override
Definition nlmcheckbox.h:30
QWidget * mainWidget() override
Definition nlmcheckbox.h:25
void init()
Definition nlmcheckbox.h:35
void setState(bool state) override
Definition nlmcheckbox.h:44
void setDisabled(bool state) override
Definition nlmcheckbox.h:52
void toggledCbk(const toggled_t &cb) override
Definition nlmcheckbox.h:20