I want to add a simple text item (one word) to a graphics scene and so use QGraphicsSimpleTextItem. The scene coordinates of the text item defines the upper left corner of the text.
Is it possible to have the text center alligned around a coordinate?
Use setPos() for this. For example, where (X,Y) is the center point to which the text must be aligned:
QGraphicsSimpleTextItem *Item;
Item->setText( QString::fromLatin1( "My text" ) );
QRectF bR = Item->sceneBoundingRect();
Item->setPos( X - bR.width()/2, Y - bR.height()/2 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With