Results 1 to 3 of 3

Thread: Drawing text with tabs, setting tab stops

  1. #1
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Drawing text with tabs, setting tab stops

    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!

  2. #2
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Drawing text with tabs, setting tab stops

    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?

  3. #3
    Join Date
    Jul 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drawing text with tabs, setting tab stops

    painter->drawText(x, y, width, height, Qt::TextExpandTabs , text);
    option Qt::TextExpandTabs

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Setting text color on QLabel
    By Yorma in forum Newbie
    Replies: 11
    Last Post: 15th June 2006, 07:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.