-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistwidget.cpp
More file actions
72 lines (56 loc) · 1.64 KB
/
Copy pathlistwidget.cpp
File metadata and controls
72 lines (56 loc) · 1.64 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "listwidget.h"
listwidget::listwidget(QWidget *parent):
QWidget(parent)
{
layout = new QHBoxLayout(this);
checkbox = new QCheckBox(this);
label = new QLabel(this);
label->setMinimumSize(QSize(1000,38));
label->setStyleSheet("background-color:#F9F9FB;color:black;");
layout->addWidget(checkbox);
layout->addWidget(label);
label->setText("列表测试");
connect(checkbox, &QCheckBox::stateChanged, this, &listwidget::checkboxstatechanged);
}
void listwidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setPen(Qt::NoPen);
painter.setBrush(QBrush(QColor("#F9F9FB")));
QRect rect = this->rect();
int roundRadius = 20;
painter.drawRoundedRect(rect, roundRadius, roundRadius);
}
void listwidget::setid(int id){
listwidget_id = id;
}
void listwidget::settitle(QString title){
label->setText(title);
}
QString listwidget::gettitle(){
return label->text();
}
int listwidget::getid(){
return listwidget_id;
}
void listwidget::setlabelchecked(){
label->setStyleSheet("background-color:#F9F9FB;color:grey;");
QFont font = label->font();
font.setStrikeOut(true);
label->setFont(font);
checkbox->setCheckState(Qt::Checked);
}
void listwidget::setlabelunchecked(){
label->setStyleSheet("background-color:#F9F9FB;color:black;");
QFont font = label->font();
font.setStrikeOut(false);
label->setFont(font);
}
void listwidget::checkboxstatechanged(){
if(checkbox->isChecked()){
setlabelchecked();
}
else setlabelunchecked();
emit getcheckboxstatement(checkbox->isChecked(),listwidget_id);
}