Results 1 to 2 of 2

Thread: BUG? item.setPos( qpf ) not working when item is part of a QGraphicsItemGroup

  1. #1
    Join Date
    Dec 2008
    Posts
    16
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default BUG? item.setPos( qpf ) not working when item is part of a QGraphicsItemGroup

    Is this intended, or shall I file a bug ? I really spent hours to trace why I was not able to place the titem_title QGraphicsTextItem at the proper position (decorating my items).

    Hope it helps others and here is code that circumvents this limitation.

    Qt Code:
    1. void
    2. QGraphicsItemGroupDERIVED::update()
    3. {
    4. #define CERRD std::Cerr
    5.  
    6. this->removeFromGroup( this->titem_title );
    7.  
    8. QTransform t;
    9.  
    10. t.setMatrix( this->transform().m11(), this->transform().m12(), 0, 0, 0, 0, 0, 0, 0 );
    11.  
    12. this->titem_title->setTransform( t );
    13.  
    14. this->titem_title->setPos( this->sceneBoundingRect().topLeft() );
    15.  
    16. this->addToGroup( this->titem_title );
    17.  
    18.  
    19.  
    20. CERRD << endl << "ITEM = " << this->name_get().toStdString() << endl;
    21.  
    22. if( this->titem_title->sceneBoundingRect().topLeft() != this->sceneBoundingRect().topLeft() )
    23. {
    24. CERRD << "*** WARNING *** setPos on titem failed." << endl;
    25. }
    26.  
    27. CERRD << "item actualpos = " << this->sceneBoundingRect().topLeft() << endl;
    28. CERRD << "titem_title actualpos = " << titem_title->sceneBoundingRect().topLeft() << endl;
    29. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    Murat

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: BUG? item.setPos( qpf ) not working when item is part of a QGraphicsItemGroup

    Could you provide a minimal compilable example reproducing the problem?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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.