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 <QDate>
43 #include <QLocale>
44 #include "qtpropertymanager.h"
45 #include "qtvariantproperty.h"
46 #include "qttreepropertybrowser.h"
47 
48 int main(int argc, char** argv)
49 {
50  QApplication app(argc, argv);
51 
52  QtVariantPropertyManager* variantManager = new QtVariantPropertyManager();
53 
54  int i = 0;
56  QString::number(i++) + QLatin1String(" Group Property"));
57 
58  QtVariantProperty* item = variantManager->addProperty(QVariant::Bool, QString::number(i++) + QLatin1String(" Bool Property"));
59  item->setValue(true);
60  topItem->addSubProperty(item);
61 
62  item = variantManager->addProperty(QVariant::Int, QString::number(i++) + QLatin1String(" Int Property"));
63  item->setValue(20);
64  item->setAttribute(QLatin1String("minimum"), 0);
65  item->setAttribute(QLatin1String("maximum"), 100);
66  item->setAttribute(QLatin1String("singleStep"), 10);
67  topItem->addSubProperty(item);
68 
69  item = variantManager->addProperty(QVariant::Int, QString::number(i++) + QLatin1String(" Int Property (ReadOnly)"));
70  item->setValue(20);
71  item->setAttribute(QLatin1String("minimum"), 0);
72  item->setAttribute(QLatin1String("maximum"), 100);
73  item->setAttribute(QLatin1String("singleStep"), 10);
74  item->setAttribute(QLatin1String("readOnly"), true);
75  topItem->addSubProperty(item);
76 
77  item = variantManager->addProperty(QVariant::Double, QString::number(i++) + QLatin1String(" Double Property"));
78  item->setValue(1.2345);
79  item->setAttribute(QLatin1String("singleStep"), 0.1);
80  item->setAttribute(QLatin1String("decimals"), 3);
81  topItem->addSubProperty(item);
82 
83  item = variantManager->addProperty(QVariant::Double, QString::number(i++) + QLatin1String(" Double Property (ReadOnly)"));
84  item->setValue(1.23456);
85  item->setAttribute(QLatin1String("singleStep"), 0.1);
86  item->setAttribute(QLatin1String("decimals"), 5);
87  item->setAttribute(QLatin1String("readOnly"), true);
88  topItem->addSubProperty(item);
89 
90  item = variantManager->addProperty(QVariant::String, QString::number(i++) + QLatin1String(" String Property"));
91  item->setValue("Value");
92  topItem->addSubProperty(item);
93 
94  item = variantManager->addProperty(QVariant::String, QString::number(i++) + QLatin1String(" String Property (Password)"));
95  item->setAttribute(QLatin1String("echoMode"), QLineEdit::Password);
96  item->setValue("Password");
97  topItem->addSubProperty(item);
98 
99  // Readonly String Property
100  item = variantManager->addProperty(QVariant::String, QString::number(i++) + QLatin1String(" String Property (ReadOnly)"));
101  item->setAttribute(QLatin1String("readOnly"), true);
102  item->setValue("readonly text");
103  topItem->addSubProperty(item);
104 
105  item = variantManager->addProperty(QVariant::Date, QString::number(i++) + QLatin1String(" Date Property"));
106  item->setValue(QDate::currentDate().addDays(2));
107  topItem->addSubProperty(item);
108 
109  item = variantManager->addProperty(QVariant::Time, QString::number(i++) + QLatin1String(" Time Property"));
110  item->setValue(QTime::currentTime());
111  topItem->addSubProperty(item);
112 
113  item = variantManager->addProperty(QVariant::DateTime, QString::number(i++) + QLatin1String(" DateTime Property"));
115  topItem->addSubProperty(item);
116 
117  item = variantManager->addProperty(QVariant::KeySequence, QString::number(i++) + QLatin1String(" KeySequence Property"));
118  item->setValue(QKeySequence(Qt::ControlModifier | Qt::Key_Q));
119  topItem->addSubProperty(item);
120 
121  item = variantManager->addProperty(QVariant::Char, QString::number(i++) + QLatin1String(" Char Property"));
122  item->setValue(QChar(386));
123  topItem->addSubProperty(item);
124 
125  item = variantManager->addProperty(QVariant::Locale, QString::number(i++) + QLatin1String(" Locale Property"));
126  item->setValue(QLocale(QLocale::Polish, QLocale::Poland));
127  topItem->addSubProperty(item);
128 
129  item = variantManager->addProperty(QVariant::Point, QString::number(i++) + QLatin1String(" Point Property"));
130  item->setValue(QPoint(10, 10));
131  topItem->addSubProperty(item);
132 
133  item = variantManager->addProperty(QVariant::PointF, QString::number(i++) + QLatin1String(" PointF Property"));
134  item->setValue(QPointF(1.2345, -1.23451));
135  item->setAttribute(QLatin1String("decimals"), 3);
136  topItem->addSubProperty(item);
137 
138  item = variantManager->addProperty(QVariant::Size, QString::number(i++) + QLatin1String(" Size Property"));
139  item->setValue(QSize(20, 20));
140  item->setAttribute(QLatin1String("minimum"), QSize(10, 10));
141  item->setAttribute(QLatin1String("maximum"), QSize(30, 30));
142  topItem->addSubProperty(item);
143 
144  item = variantManager->addProperty(QVariant::SizeF, QString::number(i++) + QLatin1String(" SizeF Property"));
145  item->setValue(QSizeF(1.2345, 1.2345));
146  item->setAttribute(QLatin1String("decimals"), 3);
147  item->setAttribute(QLatin1String("minimum"), QSizeF(0.12, 0.34));
148  item->setAttribute(QLatin1String("maximum"), QSizeF(20.56, 20.78));
149  topItem->addSubProperty(item);
150 
151  item = variantManager->addProperty(QVariant::Rect, QString::number(i++) + QLatin1String(" Rect Property"));
152  item->setValue(QRect(10, 10, 20, 20));
153  topItem->addSubProperty(item);
154  item->setAttribute(QLatin1String("constraint"), QRect(0, 0, 50, 50));
155 
156  item = variantManager->addProperty(QVariant::RectF, QString::number(i++) + QLatin1String(" RectF Property"));
157  item->setValue(QRectF(1.2345, 1.2345, 1.2345, 1.2345));
158  topItem->addSubProperty(item);
159  item->setAttribute(QLatin1String("constraint"), QRectF(0, 0, 50, 50));
160  item->setAttribute(QLatin1String("decimals"), 3);
161 
162  item = variantManager->addProperty(QtVariantPropertyManager::enumTypeId(),
163  QString::number(i++) + QLatin1String(" Enum Property"));
164  QStringList enumNames;
165  enumNames << "Enum0" << "Enum1" << "Enum2";
166  item->setAttribute(QLatin1String("enumNames"), enumNames);
167  item->setValue(1);
168  topItem->addSubProperty(item);
169 
170  item = variantManager->addProperty(QtVariantPropertyManager::flagTypeId(),
171  QString::number(i++) + QLatin1String(" Flag Property"));
172  QStringList flagNames;
173  flagNames << "Flag0" << "Flag1" << "Flag2";
174  item->setAttribute(QLatin1String("flagNames"), flagNames);
175  item->setValue(5);
176  topItem->addSubProperty(item);
177 
178  item = variantManager->addProperty(QVariant::SizePolicy, QString::number(i++) + QLatin1String(" SizePolicy Property"));
179  topItem->addSubProperty(item);
180 
181  item = variantManager->addProperty(QVariant::Font, QString::number(i++) + QLatin1String(" Font Property"));
182  topItem->addSubProperty(item);
183 
184  item = variantManager->addProperty(QVariant::Cursor, QString::number(i++) + QLatin1String(" Cursor Property"));
185  topItem->addSubProperty(item);
186 
187  item = variantManager->addProperty(QVariant::Color, QString::number(i++) + QLatin1String(" Color Property"));
188  topItem->addSubProperty(item);
189 
190  QtVariantEditorFactory* variantFactory = new QtVariantEditorFactory();
191 
192  QtTreePropertyBrowser* variantEditor = new QtTreePropertyBrowser();
193  variantEditor->setFactoryForManager(variantManager, variantFactory);
194  variantEditor->addProperty(topItem);
195  variantEditor->setPropertiesWithoutValueMarked(true);
196  variantEditor->setRootIsDecorated(false);
197 
198  variantEditor->show();
199 
200  int ret = app.exec();
201 
202  delete variantManager;
203  delete variantFactory;
204  delete variantEditor;
205 
206  return ret;
207 }
QtVariantPropertyManager::addProperty
virtual QtVariantProperty * addProperty(int propertyType, const QString &name=QString())
Definition: qtvariantproperty.cpp:1403
QtAbstractPropertyBrowser::addProperty
QtBrowserItem * addProperty(QtProperty *property)
Definition: qtpropertybrowser.cpp:1969
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
QtTreePropertyBrowser
The QtTreePropertyBrowser class provides QTreeWidget based property browser.
Definition: qttreepropertybrowser.h:51
armarx::VariantType::Bool
const VariantTypeId Bool
Definition: Variant.h:915
QtVariantPropertyManager
The QtVariantPropertyManager class provides and manages QVariant based properties.
Definition: qtvariantproperty.h:75
QtProperty
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:71
armarx::VariantType::Double
const VariantTypeId Double
Definition: Variant.h:919
QtTreePropertyBrowser::setRootIsDecorated
void setRootIsDecorated(bool show)
Definition: qttreepropertybrowser.cpp:989
currentDateTime
std::string currentDateTime()
Definition: XMLScenarioParser.cpp:60
QtVariantProperty
The QtVariantProperty class is a convenience class handling QVariant based properties.
Definition: qtvariantproperty.h:55
Color
uint32_t Color
RGBA color.
Definition: color.h:8
qtvariantproperty.h
main
int main(int argc, char *argv[])
Definition: main.cpp:31
visionx::Point
Eigen::Vector3f Point
Definition: ObjectShapeClassification.h:69
QtVariantPropertyManager::groupTypeId
static int groupTypeId()
Definition: qtvariantproperty.cpp:115
QtVariantEditorFactory
The QtVariantEditorFactory class provides widgets for properties created by QtVariantPropertyManager ...
Definition: qtvariantproperty.h:162
QtVariantProperty::setValue
void setValue(const QVariant &value)
Definition: qtvariantproperty.cpp:272
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
qttreepropertybrowser.h
QtProperty::addSubProperty
void addSubProperty(QtProperty *property)
Definition: qtpropertybrowser.cpp:427
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
cxxopts::String
std::string String
Definition: cxxopts.hpp:209
QtVariantPropertyManager::flagTypeId
static int flagTypeId()
Definition: qtvariantproperty.cpp:101
QtVariantProperty::setAttribute
void setAttribute(const QString &attribute, const QVariant &value)
Definition: qtvariantproperty.cpp:286
QtVariantPropertyManager::enumTypeId
static int enumTypeId()
Definition: qtvariantproperty.cpp:87
QtTreePropertyBrowser::setPropertiesWithoutValueMarked
void setPropertiesWithoutValueMarked(bool mark)
Definition: qttreepropertybrowser.cpp:1245
QtAbstractPropertyBrowser::setFactoryForManager
void setFactoryForManager(PropertyManager *manager, QtAbstractEditorFactory< PropertyManager > *factory)
Definition: qtpropertybrowser.h:304
qtpropertymanager.h