Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
listwidgeteditor.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
5#include <designerpropertymanager.h>
6#include <abstractformbuilder.h>
7
8#include <QtDesigner/abstractsettings.h>
9#include <QtDesigner/abstractformeditor.h>
10
11#include <QtWidgets/qcombobox.h>
12#include <QtWidgets/qgroupbox.h>
13#include <QtWidgets/qdialogbuttonbox.h>
14
16
17namespace qdesigner_internal {
18
19ListWidgetEditor::ListWidgetEditor(QDesignerFormWindowInterface *form,
20 QWidget *parent)
21 : QDialog(parent)
22{
23 QDialogButtonBox *buttonBox = new QDialogButtonBox;
24 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
25 connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
26 connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
27
28 m_itemsEditor = new ItemListEditor(form, nullptr);
29 m_itemsEditor->layout()->setContentsMargins(QMargins());
30 m_itemsEditor->setNewItemText(tr("New Item"));
31
32 QFrame *sep = new QFrame;
33 sep->setFrameStyle(QFrame::HLine | QFrame::Sunken);
34
35 QBoxLayout *box = new QVBoxLayout(this);
36 box->addWidget(m_itemsEditor);
37 box->addWidget(sep);
38 box->addWidget(buttonBox);
39
40 // Numbers copied from itemlisteditor.ui
41 // (Automatic resizing doesn't work because ui has parent).
42 resize(550, 360);
43}
44
59
61{
62 setWindowTitle(tr("Edit List Widget"));
63
64 ListContents retVal;
65 retVal.createFromListWidget(listWidget, false);
66 retVal.applyToListWidget(m_itemsEditor->listWidget(), m_itemsEditor->iconCache(), true);
67
68 m_itemsEditor->setupEditor(listWidget, listBoxPropList);
69
70 return retVal;
71}
72
78
80{
81 setWindowTitle(tr("Edit Combobox"));
82
83 ListContents retVal;
84 retVal.createFromComboBox(comboBox);
85 retVal.applyToListWidget(m_itemsEditor->listWidget(), m_itemsEditor->iconCache(), true);
86
87 m_itemsEditor->setupEditor(comboBox, comboBoxPropList);
88
89 return retVal;
90}
91
93{
94 ListContents retVal;
95 retVal.createFromListWidget(m_itemsEditor->listWidget(), true);
96 return retVal;
97}
98
99} // namespace qdesigner_internal
100
101QT_END_NAMESPACE
friend class QWidget
Definition qpainter.h:421
ListContents fillContentsFromComboBox(QComboBox *comboBox)
ListContents fillContentsFromListWidget(QListWidget *listWidget)
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static AbstractItemEditor::PropertyDefinition listBoxPropList[]
static AbstractItemEditor::PropertyDefinition comboBoxPropList[]