Hi,
I will be drawing a lot of text on a widget which user can resize to any size.
The text should grow or shrink according to the widget size.
One simple solution is to set normal font size on qpainter first and then in a loop increase or decrease the font size by 2 points(or 1?)
Qt Code:
while(fm.width(text)<this->width()) { //increase font } //similar loops for greater width and heightTo copy to clipboard, switch view to plain text mode
i have to draw several lines of text, in irregular shapes (triangles, diamonds, squares, etc). And also need to draw Tables. So as u can assume that the above litter code for determining the size will become complicated.
i just wanna know if anybody done this before in a more elegant way??
recently there is a QPainter::scale() function... but ppl say it cant render the font properly at all sizes....
PS: the "text" to draw is dynamically changing every now and then.. so i cant optimize just by calculating the size just once in every resizeEvent only.
Bookmarks