Debian Codegraph @

kysdk-qtwidgets/test/testAddFileButton/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 "kaddfilebutton.h"
24 #include <QAbstractItemDelegate>
25 #include <QBoxLayout>
26 #include <QDebug>
27 #include <QTreeView>
28
29 using namespace kdk;
30 Widget::Widget(QWidget *parent)
31 : QWidget(parent)
32 {
33 QTreeView *view = new QTreeView(this);
34 QHBoxLayout *layout = new QHBoxLayout(view);
35 KAddFileButton *button1 = new KAddFileButton();
36 KAddFileButton *button2 = new KAddFileButton();
37 QStringList list;
38 list << "JPEG Files(*.jpg)"
39 << "PNG Files(*.png)";
40 button2->setNameFilters(list);
41
42 layout->addWidget(button1);
43 layout->addWidget(button2);
44
45 connect(button1, &KAddFileButton::clicked, [=] {
46 qDebug() << "button1 选择路径" << button1->fileDialog()->selectedFiles();
47 });
48 connect(button2, &KAddFileButton::clicked, [=] {
49 qDebug() << "button2 选择路径" << button2->fileDialog()->selectedFiles();
50 });
51
52 setFixedSize(600, 500);
53 }
54
55 Widget::~Widget()
56 {
57 }