PDA

View Full Version : QtVariantPropertyManager - Read Only types



NewQtProgrammer
18th June 2010, 08:17
Hi,

I've been trying to set up a series of basic types for use with a QtPropertyBrowser but I can't seem to make the children of a read only property be read only as well.

For example:

I have an QObject that has a member that is a read only axis aligned bounding box property (a custom type I added). That AABB (axis aligned bounding box) is in turn composed of two vectors (the vectors are composed of XYZ and are also a custom type I added).

I would like the two vectors and the components of those vectors to be read only but I don't understand what I need to set up to make that happen.

Following the examples I have a read only property manager and an editable property manager. I constructed the AABB property from read only manager, but somehow its child properties manage to find a factory to create editors with. Strangely enough, if I add a double property to the read only manager itself, that double is not editable.

When I create the AABB it looks like:


void AABB3F_PropertyManager::initializeProperty( QtProperty *property )
{
d_ptr->mValues[ property ] = AABB3F_PropertyManagerPrivate::Data();

QtVariantProperty* minProp = d_ptr->mVariantPropertyManager->addProperty( qMetaTypeId< Vector3F_Property >(), "Min" );
QtVariantProperty* maxProp = d_ptr->mVariantPropertyManager->addProperty( qMetaTypeId< Vector3F_Property >(), "Max" );

Vector3F_Property p;
p.x = p.y = p.z = 0;

d_ptr->mVariantPropertyManager->setValue( minProp, qVariantFromValue( p ) );
d_ptr->mVariantPropertyManager->setValue( maxProp, qVariantFromValue( p ) );

d_ptr->mPropertyToMin[ property ] = minProp;
d_ptr->mPropertyToMax[ property ] = maxProp;

d_ptr->mMinToProperty[ minProp ] = property;
d_ptr->mMaxToProperty[ maxProp ] = property;

property->addSubProperty( minProp );
property->addSubProperty( maxProp );
}


I construct the property managers like so:



{
mVariantManager = new VariantManager( this );
mReadOnlyVariantManager = new VariantManager( this );

mVariantFactory = new QtVariantEditorFactory( this );

setFactoryForManager( mVariantManager, mVariantFactory );
}


Could anyone point me in the right direction? I find the property browser quite confusing. Even adding a couple of new types was a lot more glue code than I expected so I'm probably doing something wrong, but I don't know what else to try right now.