itom
Loading...
Searching...
No Matches
QPropertyEditorWidget Class Reference

The QPropertyEditorWidget offers an easy to use mechanism to visualize properties of a class inherited from QObject. More...

#include <QPropertyEditorWidget.h>

Inheritance diagram for QPropertyEditorWidget:

Public Types

typedef Property *(*) UserTypeCB(const QString &name, QObject *propertyObject, Property *parent)
 

Public Slots

void setGroupByInheritance (bool enabled)
 
void setNameFilterPattern (const QString &wildcardPattern)
 

Public Member Functions

 QPropertyEditorWidget (QWidget *parent=0)
 Constructor.
 
virtual ~QPropertyEditorWidget ()
 Destructor.
 
void addObject (QObject *propertyObject)
 
void setObject (QObject *propertyObject)
 
void updateObject (QObject *propertyObject)
 
void registerCustomPropertyCB (UserTypeCB callback)
 
void unregisterCustomPropertyCB (UserTypeCB callback)
 
void setSorted (bool enabled)
 
bool sorted () const
 
bool groupByInheritance () const
 
QString nameFilterPattern () const
 
 QPropertyEditorWidget (QWidget *parent=0)
 Constructor.
 
virtual ~QPropertyEditorWidget ()
 Destructor.
 
void addObject (QObject *propertyObject)
 
void setObject (QObject *propertyObject)
 
void updateObject (QObject *propertyObject)
 
void registerCustomPropertyCB (UserTypeCB callback)
 
void unregisterCustomPropertyCB (UserTypeCB callback)
 
void setSorted (bool value)
 
bool sorted () const
 

Protected Member Functions

void mousePressEvent (QMouseEvent *event)
 
void keyPressEvent (QKeyEvent *event)
 
void mousePressEvent (QMouseEvent *event)
 
void keyPressEvent (QKeyEvent *event)
 

Properties

bool groupByInheritance
 
QString nameFilterPattern
 

Private Slots

void sortedAction (bool checked)
 
void dataChanged ()
 

Private Member Functions

 Q_DECLARE_PRIVATE (QPropertyEditorWidget)
 

Private Attributes

QScopedPointer< QPropertyEditorWidgetPrivated_ptr
 
QPropertyModelm_model
 The Model for this view.
 
bool m_sorted
 

Detailed Description

The QPropertyEditorWidget offers an easy to use mechanism to visualize properties of a class inherited from QObject.

QPropertyEditor

The main purpose for the QPropertyEditor is the visualization and manipulation of properties defined via the Q_PROPERTY macro in QObject based classes.

Qt provides a nice way to define class properties by using the Q_PROPERTY macro. The purpose of the QPropertyEditor is to visualize these properties in an easy way.

To use the property editor, all you have to do is to create a class that defines it's properties by using Q_PROPERTY and to add this class by using the addObject() method of this QPropertyEditorWidget class. The QPropertyEditorWidget is inherited from QTreeView and will display the properties in a tree with two columns: Name and Value

For basic data types the build in editor widgets of Qt will be used. The QPropertyEditor itself only defines an additional editor for QColor (based on the Color Editor Factory Example from Trolltech). But it can easily be extended by yourself either within the library or for special datatypes also outside of the library in your application.

Qt provides a nice way to define class properties by using the Q_PROPERTY macro. The purpose of the QPropertyEditor is to visualize these properties in an easy way.

To use the property editor, all you have to do is to create a class that defines it's properties by using Q_PROPERTY and to add this class by using the addObject() method of this QPropertyEditorWidget class. The QPropertyEditorWidget is inherited from QTreeView and will display the properties in a tree with two columns: Name and Value

For basic data types the build in editor widgets of Qt will be used. The QPropertyEditor itself only defines an additional editor for QColor (based on the Color Editor Factory Example from Trolltech). But it can easily be extended by yourself either within the library or for special datatypes also outside of the library in your application.

Member Typedef Documentation

◆ UserTypeCB

typedef Property *(* QPropertyEditorWidget::UserTypeCB)(const QString &name, QObject *propertyObject, Property *parent)

A typedef for a callback used to create user defined properties for custom datatypes

Constructor & Destructor Documentation

◆ QPropertyEditorWidget() [1/2]

QPropertyEditorWidget::QPropertyEditorWidget ( QWidget * parent = 0)

Constructor.

Creates a new editor widget based on QTreeView

Parameters
parentoptional parent widget

◆ QPropertyEditorWidget() [2/2]

QPropertyEditorWidget::QPropertyEditorWidget ( QWidget * parent = 0)

Constructor.

Creates a new editor widget based on QTreeView

Parameters
parentoptional parent widget

Member Function Documentation

◆ addObject() [1/2]

void QPropertyEditorWidget::addObject ( QObject * propertyObject)

Adds the user properties of the given class to the QPropertyModel associated with this view

Parameters
propertyObjectthe class inherited from QObject that contains user properties that should be managed by the QPropertyModel associated with this view

◆ addObject() [2/2]

void QPropertyEditorWidget::addObject ( QObject * propertyObject)

Adds the user properties of the given class to the QPropertyModel associated with this view

Parameters
propertyObjectthe class inherited from QObject that contains user properties that should be managed by the QPropertyModel associated with this view

◆ registerCustomPropertyCB() [1/2]

void QPropertyEditorWidget::registerCustomPropertyCB ( UserTypeCB callback)

If you define custom datatypes outside of this library the QPropertyModel will check if you also defined a callback that is responsible to create custom property classes inherited from Property to handle these datatypes. With this method you can register such a callback that will create custom properties for custom datatypes.

◆ registerCustomPropertyCB() [2/2]

void QPropertyEditorWidget::registerCustomPropertyCB ( UserTypeCB callback)

If you define custom datatypes outside of this library the QPropertyModel will check if you also defined a callback that is responsible to create custom property classes inherited from Property to handle these datatypes. With this method you can register such a callback that will create custom properties for custom datatypes.

◆ setObject() [1/2]

void QPropertyEditorWidget::setObject ( QObject * propertyObject)

Similar to the addObject() method this method adds the properties of the given class to the QPropertyModel associated with this view. But in contrast to addObject() it will clear the model before, removing all previously added objects.

Parameters
propertyObjectthe class inherited from QObject that contains user properties that should be managed by the QPropertyModel associated with this view

◆ setObject() [2/2]

void QPropertyEditorWidget::setObject ( QObject * propertyObject)

Similar to the addObject() method this method adds the properties of the given class to the QPropertyModel associated with this view. But in contrast to addObject() it will clear the model before, removing all previously added objects.

Parameters
propertyObjectthe class inherited from QObject that contains user properties that should be managed by the QPropertyModel associated with this view

◆ unregisterCustomPropertyCB() [1/2]

void QPropertyEditorWidget::unregisterCustomPropertyCB ( UserTypeCB callback)

You can register more than one callback. If one of those callbacks are not used any longer, you can unregister it with this method

◆ unregisterCustomPropertyCB() [2/2]

void QPropertyEditorWidget::unregisterCustomPropertyCB ( UserTypeCB callback)

You can register more than one callback. If one of those callbacks are not used any longer, you can unregister it with this method

◆ updateObject() [1/2]

void QPropertyEditorWidget::updateObject ( QObject * propertyObject)

Updates the view for the given object. This can be useful if a property was changed programmatically instead of using the view. In this case the view normally will display the new property values only after the user clicked on it. To overcome this problem you can call updateObject with the object whose property was changed.

◆ updateObject() [2/2]

void QPropertyEditorWidget::updateObject ( QObject * propertyObject)

Updates the view for the given object. This can be useful if a property was changed programmatically instead of using the view. In this case the view normally will display the new property values only after the user clicked on it. To overcome this problem you can call updateObject with the object whose property was changed.

Member Data Documentation

◆ d_ptr

QScopedPointer<QPropertyEditorWidgetPrivate> QPropertyEditorWidget::d_ptr
private

< self-managed pointer to the private class container (deletes itself if d_ptr is destroyed). pointer to private class of AddInBase defined in AddInInterface.cpp. This container is used to allow flexible changes in the interface without destroying the binary compatibility


The documentation for this class was generated from the following files: