muenalan
26th August 2009, 15:16
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.
void
QGraphicsItemGroupDERIVED::update()
{
#define CERRD std::Cerr
this->removeFromGroup( this->titem_title );
QTransform t;
t.setMatrix( this->transform().m11(), this->transform().m12(), 0, 0, 0, 0, 0, 0, 0 );
this->titem_title->setTransform( t );
this->titem_title->setPos( this->sceneBoundingRect().topLeft() );
this->addToGroup( this->titem_title );
CERRD << endl << "ITEM = " << this->name_get().toStdString() << endl;
if( this->titem_title->sceneBoundingRect().topLeft() != this->sceneBoundingRect().topLeft() )
{
CERRD << "*** WARNING *** setPos on titem failed." << endl;
}
CERRD << "item actualpos = " << this->sceneBoundingRect().topLeft() << endl;
CERRD << "titem_title actualpos = " << titem_title->sceneBoundingRect().topLeft() << endl;
}
Cheers,
Murat
Hope it helps others and here is code that circumvents this limitation.
void
QGraphicsItemGroupDERIVED::update()
{
#define CERRD std::Cerr
this->removeFromGroup( this->titem_title );
QTransform t;
t.setMatrix( this->transform().m11(), this->transform().m12(), 0, 0, 0, 0, 0, 0, 0 );
this->titem_title->setTransform( t );
this->titem_title->setPos( this->sceneBoundingRect().topLeft() );
this->addToGroup( this->titem_title );
CERRD << endl << "ITEM = " << this->name_get().toStdString() << endl;
if( this->titem_title->sceneBoundingRect().topLeft() != this->sceneBoundingRect().topLeft() )
{
CERRD << "*** WARNING *** setPos on titem failed." << endl;
}
CERRD << "item actualpos = " << this->sceneBoundingRect().topLeft() << endl;
CERRD << "titem_title actualpos = " << titem_title->sceneBoundingRect().topLeft() << endl;
}
Cheers,
Murat