PDA

View Full Version : QGraphicsRectItem with text



Nezgal
24th May 2013, 20:14
Hi!

I'm very new at Qt and I need to be able to write text in a QGraphicsRectItem. I tried making a class inheriting from QGraphicsRectItem and QGraphicsTextItem and then use setPlainText but the text won't show up. What do I have to do and how?
I'm using Python.

Thank you very much!

wysota
24th May 2013, 20:31
Place a QGraphicsTextItem as child of QGraphicsRectItem.

Nezgal
24th May 2013, 22:09
Thank you :)

New question: how can I manage to display the text (which will just be a number) in the center of the QGraphicsRectItem? I can't seem to find any alignment method in the QGraphicsTextItem class.

Thank you again!