Results 1 to 1 of 1

Thread: QToolTip doesnt wrap text

  1. #1
    Join Date
    Jul 2011
    Thanked 1 Time in 1 Post
    Qt products
    Unix/X11 Windows

    Question QToolTip doesnt wrap text

    I have a QTreeView and some of the items text gets truncated.
    I want to display a tooltip for those items. The thing is that when i display the tooltip, its also truncated.

    The word wrap only works with spaces. In my case i have a long email, and it cuts me the last 3 or 4 chars. i've tried adding the <p> tags so its rich text, and also just setting it with plain text, but still not working.
    Qt Code:
    1. item->setToolTip(tooltip);
    2. item->setToolTip("<p>" + tooltip+ "</p>"); //both have the same result
    To copy to clipboard, switch view to plain text mode 

    The hack that i found is that, if i add as many " " (blanks) as the size of the text, then it gets displayed fine.

    Qt Code:
    1. QString filler;
    2. filler.fill(' ', tooltip.size());//we need this filler ir order for QT to not cut the long text in the tooltip.
    3. item->setToolTip(tooltip + filler);
    To copy to clipboard, switch view to plain text mode 

    If instead of using a variable i set a large text manually, it works great.
    Qt Code:
    1. item->setToolTip("ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttX");
    To copy to clipboard, switch view to plain text mode 

    any ideas?
    Last edited by superpacko; 16th August 2011 at 22:18. Reason: updated contents

Similar Threads

  1. How to wrap text in a label?
    By sasi in forum Qt Programming
    Replies: 5
    Last Post: 22nd October 2016, 05:14
  2. text indent with wrap
    By linuxsong in forum Qt Quick
    Replies: 1
    Last Post: 26th July 2011, 15:14
  3. Custom Delegate and Text Wrap
    By enlightened_j in forum Newbie
    Replies: 2
    Last Post: 17th September 2010, 07:21
  4. Wrap Text in PUSHBUTTON
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2009, 14:54
  5. how can I make a balloon to wrap the editable text?
    By learning_qt in forum Qt Programming
    Replies: 9
    Last Post: 20th January 2009, 16:09

Tags for this Thread


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.