main.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the Qt Solutions component.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
19 ** distribution.
20 ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21 ** of its contributors may be used to endorse or promote products derived
22 ** from this software without specific prior written permission.
23 **
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40 
41 #include <QApplication>
42 #include <QScrollArea>
43 #include <QGridLayout>
44 #include <QLabel>
45 #include <QIcon>
46 #include <QMap>
47 #include "qtpropertymanager.h"
48 #include "qteditorfactory.h"
49 #include "qttreepropertybrowser.h"
52 
53 int main(int argc, char** argv)
54 {
55  QApplication app(argc, argv);
56 
57  QWidget* w = new QWidget();
58 
59  QtBoolPropertyManager* boolManager = new QtBoolPropertyManager(w);
60  QtIntPropertyManager* intManager = new QtIntPropertyManager(w);
61  QtStringPropertyManager* stringManager = new QtStringPropertyManager(w);
62  QtSizePropertyManager* sizeManager = new QtSizePropertyManager(w);
63  QtRectPropertyManager* rectManager = new QtRectPropertyManager(w);
64  QtSizePolicyPropertyManager* sizePolicyManager = new QtSizePolicyPropertyManager(w);
65  QtEnumPropertyManager* enumManager = new QtEnumPropertyManager(w);
66  QtGroupPropertyManager* groupManager = new QtGroupPropertyManager(w);
67 
68  QtProperty* item0 = groupManager->addProperty("QObject");
69 
70  QtProperty* item1 = stringManager->addProperty("objectName");
71  item0->addSubProperty(item1);
72 
73  QtProperty* item2 = boolManager->addProperty("enabled");
74  item0->addSubProperty(item2);
75 
76  QtProperty* item3 = rectManager->addProperty("geometry");
77  item0->addSubProperty(item3);
78 
79  QtProperty* item4 = sizePolicyManager->addProperty("sizePolicy");
80  item0->addSubProperty(item4);
81 
82  QtProperty* item5 = sizeManager->addProperty("sizeIncrement");
83  item0->addSubProperty(item5);
84 
85  QtProperty* item7 = boolManager->addProperty("mouseTracking");
86  item0->addSubProperty(item7);
87 
88  QtProperty* item8 = enumManager->addProperty("direction");
89  QStringList enumNames;
90  enumNames << "Up" << "Right" << "Down" << "Left";
91  enumManager->setEnumNames(item8, enumNames);
92  QMap<int, QIcon> enumIcons;
93  enumIcons[0] = QIcon(":/demo/images/up.png");
94  enumIcons[1] = QIcon(":/demo/images/right.png");
95  enumIcons[2] = QIcon(":/demo/images/down.png");
96  enumIcons[3] = QIcon(":/demo/images/left.png");
97  enumManager->setEnumIcons(item8, enumIcons);
98  item0->addSubProperty(item8);
99 
100  QtProperty* item9 = intManager->addProperty("value");
101  intManager->setRange(item9, -100, 100);
102  item0->addSubProperty(item9);
103 
104  QtCheckBoxFactory* checkBoxFactory = new QtCheckBoxFactory(w);
105  QtSpinBoxFactory* spinBoxFactory = new QtSpinBoxFactory(w);
106  QtSliderFactory* sliderFactory = new QtSliderFactory(w);
107  QtScrollBarFactory* scrollBarFactory = new QtScrollBarFactory(w);
108  QtLineEditFactory* lineEditFactory = new QtLineEditFactory(w);
109  QtEnumEditorFactory* comboBoxFactory = new QtEnumEditorFactory(w);
110 
112  editor1->setFactoryForManager(boolManager, checkBoxFactory);
113  editor1->setFactoryForManager(intManager, spinBoxFactory);
114  editor1->setFactoryForManager(stringManager, lineEditFactory);
115  editor1->setFactoryForManager(sizeManager->subIntPropertyManager(), spinBoxFactory);
116  editor1->setFactoryForManager(rectManager->subIntPropertyManager(), spinBoxFactory);
117  editor1->setFactoryForManager(sizePolicyManager->subIntPropertyManager(), spinBoxFactory);
118  editor1->setFactoryForManager(sizePolicyManager->subEnumPropertyManager(), comboBoxFactory);
119  editor1->setFactoryForManager(enumManager, comboBoxFactory);
120 
121  editor1->addProperty(item0);
122 
124  editor2->addProperty(item0);
125 
127  editor3->setFactoryForManager(boolManager, checkBoxFactory);
128  editor3->setFactoryForManager(intManager, spinBoxFactory);
129  editor3->setFactoryForManager(stringManager, lineEditFactory);
130  editor3->setFactoryForManager(sizeManager->subIntPropertyManager(), spinBoxFactory);
131  editor3->setFactoryForManager(rectManager->subIntPropertyManager(), spinBoxFactory);
132  editor3->setFactoryForManager(sizePolicyManager->subIntPropertyManager(), spinBoxFactory);
133  editor3->setFactoryForManager(sizePolicyManager->subEnumPropertyManager(), comboBoxFactory);
134  editor3->setFactoryForManager(enumManager, comboBoxFactory);
135 
136  editor3->addProperty(item0);
137 
138  QScrollArea* scroll3 = new QScrollArea();
139  scroll3->setWidgetResizable(true);
140  scroll3->setWidget(editor3);
141 
143  editor4->setFactoryForManager(boolManager, checkBoxFactory);
144  editor4->setFactoryForManager(intManager, scrollBarFactory);
145  editor4->setFactoryForManager(stringManager, lineEditFactory);
146  editor4->setFactoryForManager(sizeManager->subIntPropertyManager(), spinBoxFactory);
147  editor4->setFactoryForManager(rectManager->subIntPropertyManager(), spinBoxFactory);
148  editor4->setFactoryForManager(sizePolicyManager->subIntPropertyManager(), sliderFactory);
149  editor4->setFactoryForManager(sizePolicyManager->subEnumPropertyManager(), comboBoxFactory);
150  editor4->setFactoryForManager(enumManager, comboBoxFactory);
151 
152  editor4->addProperty(item0);
153 
154  QScrollArea* scroll4 = new QScrollArea();
155  scroll4->setWidgetResizable(true);
156  scroll4->setWidget(editor4);
157 
159  editor5->setFactoryForManager(boolManager, checkBoxFactory);
160  editor5->setFactoryForManager(intManager, scrollBarFactory);
161  editor5->setFactoryForManager(stringManager, lineEditFactory);
162  editor5->setFactoryForManager(sizeManager->subIntPropertyManager(), spinBoxFactory);
163  editor5->setFactoryForManager(rectManager->subIntPropertyManager(), spinBoxFactory);
164  editor5->setFactoryForManager(sizePolicyManager->subIntPropertyManager(), sliderFactory);
165  editor5->setFactoryForManager(sizePolicyManager->subEnumPropertyManager(), comboBoxFactory);
166  editor5->setFactoryForManager(enumManager, comboBoxFactory);
167 
168  editor5->addProperty(item0);
169 
170  QScrollArea* scroll5 = new QScrollArea();
171  scroll5->setWidgetResizable(true);
172  scroll5->setWidget(editor5);
173 
174  QGridLayout* layout = new QGridLayout(w);
175  QLabel* label1 = new QLabel("Editable Tree Property Browser");
176  QLabel* label2 = new QLabel("Read Only Tree Property Browser, editor factories are not set");
177  QLabel* label3 = new QLabel("Group Box Property Browser");
178  QLabel* label4 = new QLabel("Group Box Property Browser with different editor factories");
179  QLabel* label5 = new QLabel("Button Property Browser");
180  label1->setWordWrap(true);
181  label2->setWordWrap(true);
182  label3->setWordWrap(true);
183  label4->setWordWrap(true);
184  label5->setWordWrap(true);
185  label1->setFrameShadow(QFrame::Sunken);
186  label2->setFrameShadow(QFrame::Sunken);
187  label3->setFrameShadow(QFrame::Sunken);
188  label4->setFrameShadow(QFrame::Sunken);
189  label5->setFrameShadow(QFrame::Sunken);
190  label1->setFrameShape(QFrame::Panel);
191  label2->setFrameShape(QFrame::Panel);
192  label3->setFrameShape(QFrame::Panel);
193  label4->setFrameShape(QFrame::Panel);
194  label5->setFrameShape(QFrame::Panel);
195  label1->setAlignment(Qt::AlignCenter);
196  label2->setAlignment(Qt::AlignCenter);
197  label3->setAlignment(Qt::AlignCenter);
198  label4->setAlignment(Qt::AlignCenter);
199  label5->setAlignment(Qt::AlignCenter);
200 
201  layout->addWidget(label1, 0, 0);
202  layout->addWidget(label2, 0, 1);
203  layout->addWidget(label3, 0, 2);
204  layout->addWidget(label4, 0, 3);
205  layout->addWidget(label5, 0, 4);
206  layout->addWidget(editor1, 1, 0);
207  layout->addWidget(editor2, 1, 1);
208  layout->addWidget(scroll3, 1, 2);
209  layout->addWidget(scroll4, 1, 3);
210  layout->addWidget(scroll5, 1, 4);
211  w->show();
212 
213  int ret = app.exec();
214  delete w;
215  return ret;
216 }
QtRectPropertyManager
The QtRectPropertyManager provides and manages QRect properties.
Definition: qtpropertymanager.h:508
QtAbstractPropertyBrowser::addProperty
QtBrowserItem * addProperty(QtProperty *property)
Definition: qtpropertybrowser.cpp:1969
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
QtSizePolicyPropertyManager::subIntPropertyManager
QtIntPropertyManager * subIntPropertyManager() const
Definition: qtpropertymanager.cpp:6216
QtAbstractPropertyManager::addProperty
QtProperty * addProperty(const QString &name=QString())
Definition: qtpropertybrowser.cpp:826
QtIntPropertyManager
The QtIntPropertyManager provides and manages int properties.
Definition: qtpropertymanager.h:70
QtTreePropertyBrowser
The QtTreePropertyBrowser class provides QTreeWidget based property browser.
Definition: qttreepropertybrowser.h:51
QtSizePropertyManager::subIntPropertyManager
QtIntPropertyManager * subIntPropertyManager() const
Definition: qtpropertymanager.cpp:3711
qtbuttonpropertybrowser.h
qteditorfactory.h
QtEnumPropertyManager::setEnumIcons
void setEnumIcons(QtProperty *property, const QMap< int, QIcon > &icons)
Definition: qtpropertymanager.cpp:5634
QtAbstractPropertyBrowser
QtAbstractPropertyBrowser provides a base class for implementing property browsers.
Definition: qtpropertybrowser.h:289
QtStringPropertyManager
The QtStringPropertyManager provides and manages QString properties.
Definition: qtpropertymanager.h:176
QtProperty
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:71
QtEnumPropertyManager::setEnumNames
void setEnumNames(QtProperty *property, const QStringList &names)
Definition: qtpropertymanager.cpp:5593
QtGroupPropertyManager
The QtGroupPropertyManager provides and manages group properties.
Definition: qtpropertymanager.h:54
QtSizePropertyManager
The QtSizePropertyManager provides and manages QSize properties.
Definition: qtpropertymanager.h:435
QtIntPropertyManager::setRange
void setRange(QtProperty *property, int minVal, int maxVal)
Definition: qtpropertymanager.cpp:990
QtScrollBarFactory
The QtScrollBarFactory class provides QScrollBar widgets for properties created by QtIntPropertyManag...
Definition: qteditorfactory.h:99
QtButtonPropertyBrowser
The QtButtonPropertyBrowser class provides a drop down QToolButton based property browser.
Definition: qtbuttonpropertybrowser.h:50
QtSpinBoxFactory
The QtSpinBoxFactory class provides QSpinBox widgets for properties created by QtIntPropertyManager o...
Definition: qteditorfactory.h:50
QtGroupBoxPropertyBrowser
The QtGroupBoxPropertyBrowser class provides a QGroupBox based property browser.
Definition: qtgroupboxpropertybrowser.h:50
QtBoolPropertyManager
The QtBoolPropertyManager class provides and manages boolean properties.
Definition: qtpropertymanager.h:107
qtgroupboxpropertybrowser.h
main
int main(int argc, char *argv[])
Definition: main.cpp:31
QtLineEditFactory
The QtLineEditFactory class provides QLineEdit widgets for properties created by QtStringPropertyMana...
Definition: qteditorfactory.h:172
QtSizePolicyPropertyManager
The QtSizePolicyPropertyManager provides and manages QSizePolicy properties.
Definition: qtpropertymanager.h:639
qttreepropertybrowser.h
QtEnumPropertyManager
The QtEnumPropertyManager provides and manages enum properties.
Definition: qtpropertymanager.h:575
QtProperty::addSubProperty
void addSubProperty(QtProperty *property)
Definition: qtpropertybrowser.cpp:427
QtCheckBoxFactory
The QtCheckBoxFactory class provides QCheckBox widgets for properties created by QtBoolPropertyManage...
Definition: qteditorfactory.h:123
QtRectPropertyManager::subIntPropertyManager
QtIntPropertyManager * subIntPropertyManager() const
Definition: qtpropertymanager.cpp:4544
QtSizePolicyPropertyManager::subEnumPropertyManager
QtEnumPropertyManager * subEnumPropertyManager() const
Definition: qtpropertymanager.cpp:6231
QtSliderFactory
The QtSliderFactory class provides QSlider widgets for properties created by QtIntPropertyManager obj...
Definition: qteditorfactory.h:75
QtEnumEditorFactory
The QtEnumEditorFactory class provides QComboBox widgets for properties created by QtEnumPropertyMana...
Definition: qteditorfactory.h:309
QtAbstractPropertyBrowser::setFactoryForManager
void setFactoryForManager(PropertyManager *manager, QtAbstractEditorFactory< PropertyManager > *factory)
Definition: qtpropertybrowser.h:304
qtpropertymanager.h