Q:

how to add text to an item Qt

My problem is that i have created a class Item that paints polygones and what i want to do is to add some text to these item...Like Class in UML we got the class name and some attributs...to be more clear i want to create a simple tool form uml class with Qt and i created a class which can paint the entity but its just a simple polygone with 2 areas one for the class name and the other for the attributs,my question is how can i add the text to the polygone with the possibility to change it...please i really need some help here and thanks to everyone.

A:

There are three ways to do that

Use QPainter::drawText() functions, and draw text directly.
Use QPainterPath::addText() and then QPaitner::fillPath() or QPainter::drawPath(), this method is more difficult because the coordinates given are the base line bottom left corner.
If you are drawing on a QGraphicsScene then a text item can be added.

