Debian Codegraph @

kysdk-qtwidgets/test/testbreadcrumb/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
26 Widget::Widget(QWidget *parent)
27 : KWidget(parent)
28 {
29 QVBoxLayout *mainLayout = new QVBoxLayout;
30 QHBoxLayout *hLayout = new QHBoxLayout;
31 KBreadCrumb *crumb = new KBreadCrumb(this);
32 // 默认是true
33 crumb->setFlat(true);
34 crumb->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
35 crumb->addTab("页面目录一");
36 crumb->addTab("页面目录二");
37 crumb->addTab("页面目录三");
38 crumb->addTab("短的");
39 crumb->addTab("长的长的长的长的长的长的");
40 crumb->setIcon(QIcon::fromTheme("dialog-info")); // 设置KBreadCrumb的图标
41 hLayout->addWidget(crumb);
42 mainLayout->addLayout(hLayout);
43
44 hLayout = new QHBoxLayout;
45 KBreadCrumb *crumb2 = new KBreadCrumb(this);
46 // 默认是true
47 crumb->setFlat(false); // 设置KBreadCrumb是否为flat类型
48 crumb2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
49 crumb2->addTab("页面目录一");
50 crumb2->addTab("页面目录二");
51 crumb2->addTab("页面目录三");
52 crumb2->addTab("短的");
53 crumb2->addTab("长的很长的特别长的特别特别长的");
54 crumb2->setIcon(QIcon::fromTheme("dialog-warning"));
55 hLayout->addWidget(crumb2);
56 mainLayout->addLayout(hLayout);
57 baseBar()->setLayout(mainLayout);
58 }
59
60 Widget::~Widget()
61 {
62 }