| 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 "kcomboboxwidget.h" |
| 24 |
#include <QDebug> |
| 25 |
#include <QGSettings/QGSettings> |
| 26 |
#include <QMenu> |
| 27 |
#include <QPushButton> |
| 28 |
|
| 29 |
using namespace kdk; |
| 30 |
Widget::Widget(QWidget *parent) |
| 31 |
: QWidget(parent) |
| 32 |
{ |
| 33 |
KComboBoxWidget *widget = new KComboBoxWidget(this); |
| 34 |
// widget->setLabelWeekSelect("111"); |
| 35 |
|
| 36 |
QStringList list; |
| 37 |
list.append("111"); |
| 38 |
list.append("222"); |
| 39 |
list.append("333"); |
| 40 |
list.append("444444444"); |
| 41 |
list.append("55555555555"); |
| 42 |
list.append("66666"); |
| 43 |
list.append("7777"); |
| 44 |
list.append("888"); |
| 45 |
widget->setStringList(list); |
| 46 |
widget->setMainText("abnfaowifoawf"); |
| 47 |
widget->menu()->setFixedWidth(200); |
| 48 |
connect(widget, &KComboBoxWidget::comBoxWidgetClicked, this, [=] { |
| 49 |
qDebug() << "xxx" << widget->getChosenList() << widget->width() << widget->menu()->size(); |
| 50 |
}); |
| 51 |
|
| 52 |
QPushButton *btn = new QPushButton(this); |
| 53 |
QMenu *menu = new QMenu(this); |
| 54 |
menu->addAction("1"); |
| 55 |
menu->addAction("2"); |
| 56 |
menu->addAction("3"); |
| 57 |
menu->addAction("4"); |
| 58 |
menu->show(); |
| 59 |
|
| 60 |
btn->move(0, 200); |
| 61 |
btn->setMenu(menu); |
| 62 |
setFixedSize(600, 500); |
| 63 |
} |
| 64 |
|
| 65 |
Widget::~Widget() |
| 66 |
{ |
| 67 |
} |