CANdevStudio
Development tool for CAN bus simulation
Loading...
Searching...
No Matches
nlmlineedit.h
Go to the documentation of this file.
1#ifndef NLMLINEEDIT_H
2#define NLMLINEEDIT_H
3
4#include <QLineEdit>
6
8
10 : qLineEdit(new QLineEdit)
11 {
12 qLineEdit->setProperty("type", "nlmItem");
13 }
14
15 void editingFinishedCbk(const textChanged_t& cb) override
16 {
17 QObject::connect(qLineEdit, &QLineEdit::editingFinished, cb);
18 }
19
20 void textChangedCbk(const textChanged_t& cb) override
21 {
22 QObject::connect(qLineEdit, &QLineEdit::textEdited, cb);
23 }
24
25 QWidget* mainWidget() override
26 {
27 return qLineEdit;
28 }
29
30 void init(const QString& placeholderText, QValidator* qValidator) override
31 {
32 qLineEdit->setFrame(false);
33 qLineEdit->setAlignment(Qt::AlignHCenter);
34 qLineEdit->setPlaceholderText(placeholderText);
35 if (qValidator != nullptr) {
36 qLineEdit->setValidator(qValidator);
37 }
38 }
39
40 void setPlaceholderText(const QString& placeholderText) override
41 {
42 qLineEdit->setPlaceholderText(placeholderText);
43 }
44
45 void setDisabled(bool state) override
46 {
47 qLineEdit->setDisabled(state);
48 }
49
50 int getTextLength() override
51 {
52 return qLineEdit->text().length();
53 }
54
55 const QString getText() override
56 {
57 return qLineEdit->text();
58 }
59
60 void setText(const QString& text) override
61 {
62 // Inserts new text and validates the result
63 qLineEdit->clear();
64 qLineEdit->insert(text);
65 }
66
67private:
68 QLineEdit* qLineEdit;
69};
70
71#endif // NLMLINEEDIT_H
Definition lineeditinterface.h:8
std::function< void()> textChanged_t
Definition lineeditinterface.h:13
Definition nlmlineedit.h:7
NLMLineEdit()
Definition nlmlineedit.h:9
const QString getText() override
Definition nlmlineedit.h:55
int getTextLength() override
Definition nlmlineedit.h:50
QWidget * mainWidget() override
Definition nlmlineedit.h:25
void init(const QString &placeholderText, QValidator *qValidator) override
Definition nlmlineedit.h:30
void editingFinishedCbk(const textChanged_t &cb) override
Definition nlmlineedit.h:15
void textChangedCbk(const textChanged_t &cb) override
Definition nlmlineedit.h:20
void setText(const QString &text) override
Definition nlmlineedit.h:60
void setPlaceholderText(const QString &placeholderText) override
Definition nlmlineedit.h:40
void setDisabled(bool state) override
Definition nlmlineedit.h:45