Results 1 to 2 of 2

Thread: Incorrect QtProperty Order on QtTreePropertyBrowser

  1. #1
    Join Date
    Dec 2009
    Posts
    15
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Incorrect QtProperty Order on QtTreePropertyBrowser

    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?

    Qt Code:
    1. void setPropertiesForManager()
    2. {
    3. QtVariantProperty *pIdentifier = mPropertyManager->addProperty(QVariant::Int, "ID");
    4. pIdentifier->setValue(mID);
    5.  
    6. QtVariantProperty *pLabel = mPropertyManager->addProperty(QVariant::String, "Label");
    7. pLabel->setValue(mItemDef);
    8.  
    9. QtVariantProperty *pXCoord = mPropertyManager->addProperty(QVariant::Int, "X");
    10. pXCoord->setValue(mNodeList[0]->x());
    11.  
    12. QtVariantProperty *pYCoord = mPropertyManager->addProperty(QVariant::Int, "Y");
    13. pYCoord->setValue(mNodeList[0]->y());
    14.  
    15. IController::getInstance()->updatePropertyBrowser(mPropertyManager);
    16. }
    17.  
    18. void updatePropertyBrowser(QtVariantPropertyManager *iPropertyManager)
    19. {
    20. this->clear();
    21.  
    22. this->mPropertyMgr = iPropertyManager;
    23.  
    24. QSet<QtProperty *>::const_iterator i = mPropertyMgr->properties().constBegin();
    25. while (i != mPropertyMgr->properties().constEnd()) {
    26. this->addProperty(*i);
    27. qDebug() << ((QtVariantProperty *)(*i))->value();
    28. ++i;
    29. }
    30.  
    31. this->setFactoryForManager(mPropertyMgr, mFactory);
    32. this->show();
    33. }
    To copy to clipboard, switch view to plain text mode 

    Thanks a lot for your helps and explanations,
    Yasemin

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Incorrect QtProperty Order on QtTreePropertyBrowser

    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.

Similar Threads

  1. Incorrect Julian Day
    By Rayven in forum Qt Programming
    Replies: 6
    Last Post: 16th November 2011, 13:10
  2. Incorrect position of QPushButton on mac
    By francis in forum Qt Programming
    Replies: 4
    Last Post: 1st March 2011, 17:34
  3. QtTreePropertyBrowser Not Obeying Stylesheet
    By stefanadelbert in forum Qt Programming
    Replies: 0
    Last Post: 12th August 2010, 01:14
  4. QtTreePropertyBrowser and tooltip
    By jobrandt in forum Qt Programming
    Replies: 1
    Last Post: 5th October 2009, 09:43
  5. Replies: 2
    Last Post: 11th August 2009, 16:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.