PDA

View Full Version : Drawing text with tabs, setting tab stops



pxide
3rd August 2006, 09:41
Hi,

I'm trying to draw text using 'QPainter::drawText(const QRect & rectangle, int flags, const QString & text, QRect * boundingRect = 0 )'. The text I'm drawing may contain tabs, so I'm passing 'Qt::TextExpandTabs' to the drawing method.

The tabs are expanded correctly, except that I don't seem to be able to control the tab stop points. The only way (as far as I know) to tell QPainter where I want them to stop is using the overloaded 'drawText()', which takes 'QTextOption' as one of it's arguments. But this method doesn't take any flags (so no way to set Qt::TextExpandTabs), so I'm stuck.

So to sum up, I want 'drawText()' to expand the tabs, and also be able to set the tab stops.

Thank you!

pxide
4th August 2006, 09:54
No replies. I must have explained my situation badly.

My problem is simple, yet I have not found a solution:
Is it possible to set the tab width when drawing text?

daein kim
23rd July 2012, 08:42
painter->drawText(x, y, width, height, Qt::TextExpandTabs , text);
option Qt::TextExpandTabs