Question

I am using the QPropertyEditor from Qt-Apps.org.

is it possible to create a class with exposed Properties where the amount of properties is runtime-dynamic? So for example you have a class which represents a vector of floats with an arbitrary length which is not known at compile time. So you have a

vector<float> myFloats;

as a class member. How to expose this as a property with the Q_PROPERTY macro. So at the end I like to have the following view in the property editor widget:

  • MyClass
    • value of myFloats[0]
    • value of myFloats[1]
    • value of myFloats[2] ... ...

Thanks in advance!

Was it helpful?

Solution

By using dynamic properties ...

In your class u can set at runtime the dynamic properties of that class

DynamicPropertiesClassForQPropertyEditor()
{
    QVector<int> properties;
    ///.... fill in thevalues
    for (int i=0 ; i!=properties.size() ; ++i )
    {
        const QString propertyName = QString( "value of properties[%1]").arg(i);
        setProperty( qPrintable(propertyName) ,properties.at(i) );
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top