Debian Codegraph @

kysdk-qtwidgets/test/testprogresslabel/widget.cpp

raw
1 /*
2 *
3 * Copyright (C) 2024, KylinSoft Co., Ltd.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this library. If not, see <https://www.gnu.org/licenses/>.
17 *
18 * Authors: Zhenyu Wang <[email protected]>
19 *
20 */
21
22 #include "widget.h"
23 #include "kprogresslabel.h"
24 #include <QDebug>
25 #include <QPushButton>
26
27 using namespace kdk;
28
29 Widget::Widget(QWidget *parent)
30 : QWidget(parent)
31 {
32 QVBoxLayout *vlayout = new QVBoxLayout(this);
33 QHBoxLayout *layout = new QHBoxLayout();
34 KProgressLabel *label = new KProgressLabel();
35 QStringList list;
36 list.append("11");
37 list.append("22");
38 list.append("33");
39 list.append("44");
40 list.append("55");
41
42 QStringList list2;
43 list2.append("1");
44 list2.append("2");
45 list2.append("3");
46 list2.append("4");
47 list2.append("5");
48 label->setStringList(list);
49 label->setCircleSize(QSize(24, 24));
50 label->setCurrentIndex(1);
51 // label->setStyleSheet("background :red");
52
53 QPushButton *btn1 = new QPushButton("");
54
55 QPushButton *btn2 = new QPushButton("");
56
57 layout->addWidget(btn1);
58 layout->addWidget(btn2);
59 vlayout->addWidget(label);
60 vlayout->addLayout(layout);
61 connect(btn1, &QPushButton::clicked, this, [=] {
62 label->setCurrentIndex(label->currentIndex() - 1);
63 qDebug() << label->size();
64 });
65 connect(btn2, &QPushButton::clicked, this, [=] {
66 label->setCurrentIndex(label->currentIndex() + 1);
67 });
68 setFixedSize(600, 500);
69 }
70
71 Widget::~Widget()
72 {
73 }