You have to check the width() of your QFontMetrics instance initialized with a QFont .
I used it to write over a QGraphicsItem on a single line.
But in ordrer to find the right size of the font, I need to loop and check by changing the font size with setPixelSize until it fits my boundaries rect size.
I didn't find any method in the documentation to get the right size from a pixel size direclty.
Be aware that if your item is scaled, the label you are writing will be scale too.
Bookmarks