Workspace 6.21.5
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QtVariantPropertyManager Class Reference

The QtVariantPropertyManager class provides and manages QVariant based properties. More...

#include <Workspace/Widgets/PropertyBrowser/qtvariantproperty.h>

Inheritance diagram for QtVariantPropertyManager:
[legend]

Public Slots

virtual void setAttribute (QtProperty *property, const QString &attribute, const QVariant &value)
 
virtual void setValue (QtProperty *property, const QVariant &val)
 

Signals

void attributeChanged (QtProperty *property, const QString &attribute, const QVariant &val)
 
void valueChanged (QtProperty *property, const QVariant &val)
 
- Signals inherited from QtAbstractPropertyManager
void propertyChanged (QtProperty *property)
 
void propertyDestroyed (QtProperty *property)
 
void propertyInserted (QtProperty *property, QtProperty *parent, QtProperty *after)
 
void propertyRemoved (QtProperty *property, QtProperty *parent)
 

Public Member Functions

 QtVariantPropertyManager (QObject *parent=nullptr)
 
 ~QtVariantPropertyManager ()
 
virtual QtVariantPropertyaddProperty (int propertyType, const QString &name=QString())
 
virtual QStringList attributes (int propertyType) const
 
virtual int attributeType (int propertyType, const QString &attribute) const
 
virtual QVariant attributeValue (const QtProperty *property, const QString &attribute) const
 
virtual bool isPropertyTypeSupported (int propertyType) const
 
int propertyType (const QtProperty *property) const
 
virtual QVariant value (const QtProperty *property) const
 
int valueType (const QtProperty *property) const
 
virtual int valueType (int propertyType) const
 
QtVariantPropertyvariantProperty (const QtProperty *property) const
 
- Public Member Functions inherited from QtAbstractPropertyManager
 QtAbstractPropertyManager (QObject *parent=nullptr)
 
 ~QtAbstractPropertyManager ()
 
QtPropertyaddProperty (const QString &name=QString())
 
void clear () const
 
bool getModifiedOnValueChanged () const
 
QSet< QtProperty * > properties () const
 
void setModifiedOnValueChanged (bool modified)
 

Static Public Member Functions

static int enumTypeId ()
 
static int flagTypeId ()
 
static int groupTypeId ()
 
static int iconMapTypeId ()
 

Protected Member Functions

virtual QtPropertycreateProperty ()
 
virtual bool hasValue (const QtProperty *property) const
 
virtual void initializeProperty (QtProperty *property)
 
virtual void uninitializeProperty (QtProperty *property)
 
QIcon valueIcon (const QtProperty *property) const
 
QString valueText (const QtProperty *property) const
 
- Protected Member Functions inherited from QtAbstractPropertyManager
virtual QtPropertycreateProperty ()
 
virtual QString displayText (const QtProperty *property) const
 
virtual EchoMode echoMode (const QtProperty *) const
 
virtual bool hasValue (const QtProperty *property) const
 
virtual void initializeProperty (QtProperty *property)=0
 
virtual void uninitializeProperty (QtProperty *property)
 
virtual QIcon valueIcon (const QtProperty *property) const
 
virtual QString valueText (const QtProperty *property) const
 

Detailed Description

QtVariantPropertyManager provides the addProperty() function which creates QtVariantProperty objects. The QtVariantProperty class is a convenience class handling QVariant based properties inheriting QtProperty. A QtProperty object created by a QtVariantPropertyManager instance can be converted into a QtVariantProperty object using the variantProperty() function.

The property's value can be retrieved using the value(), and set using the setValue() slot. In addition the property's type, and the type of its value, can be retrieved using the propertyType() and valueType() functions respectively.

A property's type is a QVariant::Type enumerator value, and usually a property's type is the same as its value type. But for some properties the types differ, for example for enums, flags and group types in which case QtVariantPropertyManager provides the enumTypeId(), flagTypeId() and groupTypeId() functions, respectively, to identify their property type (the value types are QVariant::Int for the enum and flag types, and QVariant::Invalid for the group type).

Use the isPropertyTypeSupported() function to check if a particular property type is supported. The currently supported property types are:

Property Type Property Type Id
int QVariant::Int
double QVariant::Double
bool QVariant::Bool
QString QVariant::String
QDate QVariant::Date
QTime QVariant::Time
QDateTime QVariant::DateTime
QKeySequence QVariant::KeySequence
QChar QVariant::Char
QLocale QVariant::Locale
QPoint QVariant::Point
QPointF QVariant::PointF
QSize QVariant::Size
QSizeF QVariant::SizeF
QRect QVariant::Rect
QRectF QVariant::RectF
QColor QVariant::Color
QSizePolicy QVariant::SizePolicy
QFont QVariant::Font
QCursor QVariant::Cursor
enum enumTypeId()
flag flagTypeId()
group groupTypeId()

Each property type can provide additional attributes, e.g. QVariant::Int and QVariant::Double provides minimum and maximum values. The currently supported attributes are:

Property Type Attribute Name Attribute Type
int minimum QVariant::Int
maximum QVariant::Int
singleStep QVariant::Int
double minimum QVariant::Double
maximum QVariant::Double
singleStep QVariant::Double
decimals QVariant::Int
QString regExp QVariant::RegExp
QDate minimum QVariant::Date
maximum QVariant::Date
QPointF decimals QVariant::Int
QSize minimum QVariant::Size
maximum QVariant::Size
QSizeF minimum QVariant::SizeF
maximum QVariant::SizeF
decimals QVariant::Int
QRect constraint QVariant::Rect
QRectF constraint QVariant::RectF
decimals QVariant::Int
enum enumNames QVariant::StringList
enumIcons iconMapTypeId()
flag flagNames QVariant::StringList

The attributes for a given property type can be retrieved using the attributes() function. Each attribute has a value type which can be retrieved using the attributeType() function, and a value accessible through the attributeValue() function. In addition, the value can be set using the setAttribute() slot.

QtVariantManager also provides the valueChanged() signal which is emitted whenever a property created by this manager change, and the attributeChanged() signal which is emitted whenever an attribute of such a property changes.

See also
QtVariantProperty, QtVariantEditorFactory

Constructor & Destructor Documentation

◆ QtVariantPropertyManager()

QtVariantPropertyManager ( QObject *  parent = nullptr)

Creates a manager with the given parent.

◆ ~QtVariantPropertyManager()

Destroys this manager, and all the properties it has created.

Member Function Documentation

◆ addProperty()

QtVariantProperty * addProperty ( int  propertyType,
const QString &  name = QString() 
)
virtual

Creates and returns a variant property of the given propertyType with the given name.

If the specified propertyType is not supported by this variant manager, this function returns 0.

Do not use the inherited QtAbstractPropertyManager::addProperty() function to create a variant property (that function will always return 0 since it will not be clear what type the property should have).

See also
isPropertyTypeSupported()

◆ attributeChanged

void attributeChanged ( QtProperty property,
const QString &  attribute,
const QVariant &  value 
)
signal

This signal is emitted whenever an attribute of a property created by this manager changes its value, passing a pointer to the property, the attribute and the new value as parameters.

See also
setAttribute()

◆ attributes()

QStringList attributes ( int  propertyType) const
virtual

Returns a list of the given propertyType 's attributes.

See also
attributeValue(), attributeType()

◆ attributeType()

int attributeType ( int  propertyType,
const QString &  attribute 
) const
virtual

Returns the type of the specified attribute of the given propertyType.

If the given propertyType is not supported by this manager, or if the given propertyType does not possess the specified attribute, this function returns QVariant::Invalid.

See also
attributes(), valueType()

◆ attributeValue()

QVariant attributeValue ( const QtProperty property,
const QString &  attribute 
) const
virtual

Returns the given property's value for the specified attribute

If the given property was not created by this manager, or if the specified attribute does not exist, this function returns an invalid variant.

See also
attributes(), attributeType(), setAttribute()

◆ createProperty()

QtProperty * createProperty ( )
protectedvirtual

Creates a property.

The base implementation produce QtProperty instances; Reimplement this function to make this manager produce objects of a QtProperty subclass.

See also
addProperty(), initializeProperty()

Reimplemented from QtAbstractPropertyManager.

◆ enumTypeId()

int enumTypeId ( )
static

Returns the type id for an enum property.

Note that the property's value type can be retrieved using the valueType() function (which is QVariant::Int for the enum property type).

See also
propertyType(), valueType()

◆ flagTypeId()

int flagTypeId ( )
static

Returns the type id for a flag property.

Note that the property's value type can be retrieved using the valueType() function (which is QVariant::Int for the flag property type).

See also
propertyType(), valueType()

◆ groupTypeId()

int groupTypeId ( )
static

Returns the type id for a group property.

Note that the property's value type can be retrieved using the valueType() function (which is QVariant::Invalid for the group property type, since it doesn't provide any value).

See also
propertyType(), valueType()

◆ hasValue()

bool hasValue ( const QtProperty property) const
protectedvirtual

Returns whether the given property has a value.

The default implementation of this function returns true.

See also
QtProperty::hasValue()

Reimplemented from QtAbstractPropertyManager.

◆ iconMapTypeId()

int iconMapTypeId ( )
static

Returns the type id for a icon map attribute.

Note that the property's attribute type can be retrieved using the attributeType() function.

See also
attributeType(), QtEnumPropertyManager::enumIcons()

◆ initializeProperty()

void initializeProperty ( QtProperty property)
protectedvirtual

This function is called whenever a new valid property pointer has been created, passing the pointer as parameter.

The purpose is to let the manager know that the property has been created so that it can provide additional attributes for the new property, e.g. QtIntPropertyManager adds {QtIntPropertyManager::value()}{value}, {QtIntPropertyManager::minimum()}{minimum} and {QtIntPropertyManager::maximum()}{maximum} attributes. Since each manager subclass adds type specific attributes, this function is pure virtual and must be reimplemented when deriving from the QtAbstractPropertyManager class.

See also
addProperty(), createProperty()

Implements QtAbstractPropertyManager.

◆ isPropertyTypeSupported()

bool isPropertyTypeSupported ( int  propertyType) const
virtual

Returns true if the given propertyType is supported by this variant manager; otherwise false.

See also
propertyType()

◆ propertyType()

int propertyType ( const QtProperty property) const

Returns the given property's type.

See also
valueType()

◆ setAttribute

void setAttribute ( QtProperty property,
const QString &  attribute,
const QVariant &  value 
)
virtualslot

Sets the value of the specified attribute of the given property, to value.

The new value's type must be of the type returned by attributeType(), or of a type that can be converted to attributeType() using the QVariant::canConvert() function, otherwise this function does nothing.

See also
attributeValue(), QtVariantProperty::setAttribute(), attributeChanged()

◆ setValue

void setValue ( QtProperty property,
const QVariant &  value 
)
virtualslot

Sets the value of the given property to value.

The specified value must be of a type returned by valueType(), or of type that can be converted to valueType() using the QVariant::canConvert() function, otherwise this function does nothing.

See also
value(), QtVariantProperty::setValue(), valueChanged()

◆ uninitializeProperty()

void uninitializeProperty ( QtProperty property)
protectedvirtual

This function is called just before the specified property is destroyed.

The purpose is to let the property manager know that the property is being destroyed so that it can remove the property's additional attributes.

See also
clear(), propertyDestroyed()

Reimplemented from QtAbstractPropertyManager.

◆ value()

QVariant value ( const QtProperty property) const
virtual

Returns the given property's value.

If the given property is not managed by this manager, this function returns an invalid variant.

See also
setValue()

◆ valueChanged

void valueChanged ( QtProperty property,
const QVariant &  value 
)
signal

This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the property and the new value as parameters.

See also
setValue()

◆ valueIcon()

QIcon valueIcon ( const QtProperty property) const
protectedvirtual

Returns an icon representing the current state of the given property.

The default implementation of this function returns an invalid icon.

See also
QtProperty::valueIcon()

Reimplemented from QtAbstractPropertyManager.

◆ valueText()

QString valueText ( const QtProperty property) const
protectedvirtual

Returns a string representing the current state of the given property.

The default implementation of this function returns an empty string.

See also
QtProperty::valueText()

Reimplemented from QtAbstractPropertyManager.

◆ valueType() [1/2]

int valueType ( const QtProperty property) const

Returns the given property's value type.

See also
propertyType()

◆ valueType() [2/2]

int valueType ( int  propertyType) const
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns the value type associated with the given propertyType.

◆ variantProperty()

QtVariantProperty * variantProperty ( const QtProperty property) const

Returns the given property converted into a QtVariantProperty.

If the property was not created by this variant manager, the function returns 0.

See also
createProperty()