1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include <QDialog>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <qapplication.h>
#include <QDebug>
#include <keditlistwidget.h>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#if 0
KEditListWidget::CustomEditor editor(new KComboBox(true, 0));
KEditListWidget *box = new KEditListWidget(editor);
box->insertItem(QStringLiteral("Test"));
box->insertItem(QStringLiteral("for"));
box->insertItem(QStringLiteral("this"));
box->insertItem(QStringLiteral("KEditListWidget"));
box->insertItem(QStringLiteral("Widget"));
box->show();
#else
// code from kexi
QStringList list;
list << QStringLiteral("one") << QStringLiteral("two");
QDialog dialog;
dialog.setObjectName(QStringLiteral("stringlist_dialog"));
dialog.setModal(true);
dialog.setWindowTitle(QStringLiteral("Edit List of Items"));
KEditListWidget *edit = new KEditListWidget(&dialog);
edit->setObjectName(QStringLiteral("editlist"));
edit->insertStringList(list);
QDialogButtonBox *buttonBox = new QDialogButtonBox(&dialog);
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QObject::connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
QObject::connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
auto *layout = new QVBoxLayout(&dialog);
layout->addWidget(edit);
layout->addWidget(buttonBox);
if (dialog.exec() == QDialog::Accepted) {
list = edit->items();
qDebug() << list;
}
#endif
return app.exec();
}
|