Debian Codegraph @

kysdk-qtwidgets/test/testPushbutton/widget.cpp

raw
1 /*
2 *
3 *
4 * Copyright (C) 2023, KylinSoft Co., Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this library. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Authors: Zhen Sun <[email protected]>
20 *
21 */
22
23 #include "widget.h"
24 #include <QBoxLayout>
25 #include <QGroupBox>
26 #include <QIcon>
27 #include <QPalette>
28
29 Widget::Widget(QWidget *parent)
30 : KWidget(parent)
31 {
32 QVBoxLayout *vLayout = new QVBoxLayout;
33 QGroupBox *groupBox1 = new QGroupBox("border", this);
34 QGroupBox *groupBox2 = new QGroupBox("borderless", this);
35 QGroupBox *groupBox3 = new QGroupBox("borderless tooltip", this);
36 QHBoxLayout *hLayout = new QHBoxLayout;
37 m_pBtn1 = new KBorderButton("border", this); // 构造一个带边框按钮
38 m_pBtn2 = new KBorderButton("border", this);
39 m_pBtn2->setIcon(QIcon::fromTheme("browser-download-symbolic")); // 设置按钮图标
40 m_pBtn3 = new KBorderButton("border", this);
41 m_pBtn3->setIcon(QIcon::fromTheme("browser-download-symbolic"));
42 m_pBtn3->setEnabled(false); // 设置不可点击
43 hLayout->addWidget(m_pBtn1);
44 hLayout->addWidget(m_pBtn2);
45 hLayout->addWidget(m_pBtn3);
46 groupBox1->setLayout(hLayout);
47 m_pBtn4 = new KBorderlessButton("borderless", this); // 构造一个无边框按钮
48 m_pBtn5 = new KBorderlessButton("borderless", this);
49 m_pBtn5->setIcon(QIcon::fromTheme("document-send-symbolic")); // 设置按钮图标
50 m_pBtn6 = new KBorderlessButton("borderless", this);
51 m_pBtn6->setIcon(QIcon::fromTheme("browser-download-symbolic"));
52 m_pBtn6->setEnabled(false); // 设置不可点击
53
54 hLayout = new QHBoxLayout;
55 hLayout->addWidget(m_pBtn4);
56 hLayout->addWidget(m_pBtn5);
57 hLayout->addWidget(m_pBtn6);
58 groupBox2->setLayout(hLayout);
59
60 KBorderlessButton *m_pBtn7 = new KBorderlessButton("borderless test", this); // 构造一个无边框按钮
61 m_pBtn7->setFixedWidth(80);
62 KBorderlessButton *m_pBtn8 = new KBorderlessButton("borderless", this);
63 m_pBtn8->setIcon(QIcon::fromTheme("document-send-symbolic")); // 设置按钮图标
64 KBorderlessButton *m_pBtn9 = new KBorderlessButton("borderless", this);
65 m_pBtn9->setFixedWidth(80);
66 m_pBtn9->setIcon(QIcon::fromTheme("browser-download-symbolic"));
67
68 hLayout = new QHBoxLayout;
69 hLayout->addWidget(m_pBtn7);
70 hLayout->addWidget(m_pBtn8);
71 hLayout->addWidget(m_pBtn9);
72
73 groupBox3->setLayout(hLayout);
74 vLayout->addWidget(groupBox1);
75 vLayout->addWidget(groupBox2);
76 vLayout->addWidget(groupBox3);
77 baseBar()->setLayout(vLayout);
78 }
79
80 Widget::~Widget()
81 {
82 }