PDA

View Full Version : Incorrect QtProperty Order on QtTreePropertyBrowser



yaseminyilmaz
22nd March 2012, 06:56
Hi all,

I have added the properties to QtTreePropertyBrowser for selected QGraphicsItem objects on QGraphicsScene. But the property order of the browser changes dynamically when I select an item. I couldn’t see the properties as the following.

Added order: ID -> Label -> X -> Y. For example, incorrect order: Label -> X -> Y -> ID. What can the problem be?




void setPropertiesForManager()
{
QtVariantProperty *pIdentifier = mPropertyManager->addProperty(QVariant::Int, "ID");
pIdentifier->setValue(mID);

QtVariantProperty *pLabel = mPropertyManager->addProperty(QVariant::String, "Label");
pLabel->setValue(mItemDef);

QtVariantProperty *pXCoord = mPropertyManager->addProperty(QVariant::Int, "X");
pXCoord->setValue(mNodeList[0]->x());

QtVariantProperty *pYCoord = mPropertyManager->addProperty(QVariant::Int, "Y");
pYCoord->setValue(mNodeList[0]->y());

IController::getInstance()->updatePropertyBrowser(mPropertyManager);
}

void updatePropertyBrowser(QtVariantPropertyManager *iPropertyManager)
{
this->clear();

this->mPropertyMgr = iPropertyManager;

QSet<QtProperty *>::const_iterator i = mPropertyMgr->properties().constBegin();
while (i != mPropertyMgr->properties().constEnd()) {
this->addProperty(*i);
qDebug() << ((QtVariantProperty *)(*i))->value();
++i;
}

this->setFactoryForManager(mPropertyMgr, mFactory);
this->show();
}


Thanks a lot for your helps and explanations,
Yasemin

d_stranz
23rd March 2012, 22:19
From the QSet documentation (with my emphasis added in bold):


Detailed Description

The QSet class is a template class that provides a hash-table-based set.

QSet<T> is one of Qt's generic container classes. It stores values in an unspecified order and provides very fast lookup of the values. Internally, QSet<T> is implemented as a QHash.

So it doesn't matter what order you add property values, the QSet will store them however it wants.