| 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 "kinputdialog.h" |
| 25 |
#include <QDebug> |
| 26 |
#include <QPushButton> |
| 27 |
#include <QVBoxLayout> |
| 28 |
|
| 29 |
using namespace kdk; |
| 30 |
Widget::Widget(QWidget *parent) |
| 31 |
: KWidget(parent) |
| 32 |
{ |
| 33 |
QVBoxLayout *vlayout = new QVBoxLayout(); |
| 34 |
auto btn1 = new QPushButton("inputText", this); |
| 35 |
auto btn2 = new QPushButton("inputMultiText", this); |
| 36 |
auto btn3 = new QPushButton("inputInt", this); |
| 37 |
auto btn4 = new QPushButton("inputDouble", this); |
| 38 |
vlayout->addWidget(btn1); |
| 39 |
vlayout->addWidget(btn2); |
| 40 |
vlayout->addWidget(btn3); |
| 41 |
vlayout->addWidget(btn4); |
| 42 |
connect(btn1, &QPushButton::clicked, this, [=]() { |
| 43 |
KInputDialog::getText(this, tr("please input:")); |
| 44 |
}); // 单行文本输入框 |
| 45 |
connect(btn2, &QPushButton::clicked, this, [=]() { |
| 46 |
KInputDialog::getMultiLineText(this, tr("please input:")); |
| 47 |
}); // 多行文本输入框 |
| 48 |
connect(btn3, &QPushButton::clicked, this, [=]() { |
| 49 |
KInputDialog::getInt(this, tr("please input:")); |
| 50 |
}); // 整型数字输入框 |
| 51 |
connect(btn4, &QPushButton::clicked, this, [=]() { |
| 52 |
KInputDialog::getDouble(this, tr("please input:")); |
| 53 |
}); // 浮点型数字输入框 |
| 54 |
baseBar()->setLayout(vlayout); |
| 55 |
} |
| 56 |
|
| 57 |
Widget::~Widget() |
| 58 |
{ |
| 59 |
} |