41#include <QApplication>
68 void slotPropertyDestroyed(
QtProperty* property);
78 QMap<const QtProperty*, Data> propertyToData;
79 QMap<const QtProperty*, QtProperty*> xToProperty;
80 QMap<const QtProperty*, QtProperty*> yToProperty;
88 SLOT(slotValueChanged(
QtProperty*,
const QVariant&)));
100VariantManager::slotValueChanged(
QtProperty* property,
const QVariant& value)
102 if (xToProperty.contains(property))
104 QtProperty* pointProperty = xToProperty[property];
105 QVariant v = this->
value(pointProperty);
106 QPointF p = v.value<QPointF>();
107 p.setX(
value.value<
double>());
110 else if (yToProperty.contains(property))
112 QtProperty* pointProperty = yToProperty[property];
113 QVariant
v = this->
value(pointProperty);
114 QPointF p =
v.value<QPointF>();
115 p.setY(
value.value<
double>());
121VariantManager::slotPropertyDestroyed(
QtProperty* property)
123 if (xToProperty.contains(property))
125 QtProperty* pointProperty = xToProperty[property];
126 propertyToData[pointProperty].x = 0;
127 xToProperty.remove(property);
129 else if (yToProperty.contains(property))
131 QtProperty* pointProperty = yToProperty[property];
132 propertyToData[pointProperty].y = 0;
133 yToProperty.remove(property);
153 return QVariant::PointF;
162 if (propertyToData.contains(property))
164 return propertyToData[property].value;
173 if (propertyToData.contains(property))
175 QVariant v = propertyToData[property].value;
176 QPointF p = v.value<QPointF>();
177 return QString(tr(
"(%1, %2)").arg(QString::number(p.x())).arg(QString::number(p.y())));
186 if (propertyToData.contains(property))
188 if (val.type() != QVariant::PointF && !val.canConvert(QVariant::PointF))
193 QPointF p = val.value<QPointF>();
194 Data d = propertyToData[property];
199 d.x->setValue(p.x());
204 d.y->setValue(p.y());
207 propertyToData[property] = d;
223 d.value = QPointF(0, 0);
229 property->addSubProperty(d.x);
230 xToProperty[d.x] = property;
234 property->addSubProperty(d.y);
235 yToProperty[d.y] = property;
237 propertyToData[property] = d;
246 if (propertyToData.contains(property))
248 Data d = propertyToData[property];
252 xToProperty.remove(d.x);
257 yToProperty.remove(d.y);
260 propertyToData.remove(property);
269 QApplication app(argc, argv);
274 item->
setValue(QPointF(2.5, 13.13));
286 int ret = app.exec();
288 delete variantFactory;
289 delete variantManager;
QtBrowserItem * addProperty(QtProperty *property)
void setFactoryForManager(PropertyManager *manager, QtAbstractEditorFactory< PropertyManager > *factory)
void propertyDestroyed(QtProperty *property)
void propertyChanged(QtProperty *property)
The QtProperty class encapsulates an instance of a property.
void setPropertyName(const QString &text)
The QtTreePropertyBrowser class provides QTreeWidget based property browser.
The QtVariantEditorFactory class provides widgets for properties created by QtVariantPropertyManager ...
The QtVariantPropertyManager class provides and manages QVariant based properties.
void initializeProperty(QtProperty *property) override
virtual QtVariantProperty * addProperty(int propertyType, const QString &name=QString())
virtual QVariant value(const QtProperty *property) const
QtVariantPropertyManager(QObject *parent=0)
virtual void setValue(QtProperty *property, const QVariant &val)
void valueChanged(QtProperty *property, const QVariant &val)
void uninitializeProperty(QtProperty *property) override
virtual bool isPropertyTypeSupported(int propertyType) const
int propertyType(const QtProperty *property) const
QString valueText(const QtProperty *property) const override
int valueType(const QtProperty *property) const
The QtVariantProperty class is a convenience class handling QVariant based properties.
void setValue(const QVariant &value)
virtual int valueType(int propertyType) const
virtual QVariant value(const QtProperty *property) const
QString valueText(const QtProperty *property) const
virtual void setValue(QtProperty *property, const QVariant &val)
virtual void uninitializeProperty(QtProperty *property)
VariantManager(QObject *parent=0)
virtual void initializeProperty(QtProperty *property)
virtual bool isPropertyTypeSupported(int propertyType) const
double v(double t, double v0, double a0, double j)
This file offers overloads of toIce() and fromIce() functions for STL container types.