Debian Codegraph @

kysdk-qtwidgets/test/testnavigationtrail/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 "knavigationtrail.h"
24 #include <QHBoxLayout>
25
26 using namespace kdk;
27 Widget::Widget(QWidget *parent)
28 : QWidget(parent)
29 {
30 QHBoxLayout *layout = new QHBoxLayout(this);
31 KNavigationTrail *trail = new KNavigationTrail();
32 KCrumb *crumb1 = trail->crumb();
33 crumb1->addTab("页面目录一,页面目录一");
34 crumb1->addTab("页面目录二,页面目录二");
35 crumb1->addTab("页面目录三,页面目录三");
36 crumb1->addTab("页面目录四,页面目录四");
37 crumb1->addTab("页面目录五,页面目录五");
38 crumb1->setFlat(false);
39 // crumb1->setIcon(QIcon::fromTheme("dialog-info")); //设置KBreadCrumb的图标
40 layout->addWidget(trail);
41 connect(crumb1, &KCrumb::tabBarClicked, this, [=](int index) {
42 if (index == 1)
43 trail->setPosition(ButtonPosition::LeftOrRight);
44 if (index == 2)
45 trail->setPosition(ButtonPosition::LeftPosition);
46 if (index == 3)
47 trail->setPosition(ButtonPosition::RightPosition);
48 });
49 }
50
51 Widget::~Widget()
52 {
53 }