-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlineedit.cpp
More file actions
45 lines (36 loc) · 887 Bytes
/
lineedit.cpp
File metadata and controls
45 lines (36 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "lineedit.h"
#include <QMouseEvent>
#include <QLabel>
#include <QPalette>
LineEdit::LineEdit(QString text, QWidget * parent):
QLineEdit(parent)
{
setText(text);
adjustSize();
setFrame(false);
setReadOnly(true);
QPalette myPalette;
myPalette.setBrush(QPalette::Base, QColor(250,234,168));
setPalette(myPalette);
setAutoFillBackground(true);
connect(this, SIGNAL(doubleClicked()),
this, SLOT(changeText()));
connect(this, SIGNAL(editingFinished()),
this, SLOT(changeTextFinished()));
}
void LineEdit::mouseDoubleClickEvent(QMouseEvent * /*event*/)
{
emit doubleClicked();
}
void LineEdit::changeText() {
setReadOnly(false);
selectAll();
}
void LineEdit::changeTextFinished() {
setReadOnly(true);
}
void LineEdit::changeColor(QColor color) {
QPalette myPalette;
myPalette.setBrush(QPalette::Base, color);
setPalette(myPalette);
}