September 27, 2011

pratik041 pratik041
Lab Rat
346 posts

How we can set tooltip of the desired width with multiple lines in a button?

 

If the length of tooltip text exceeds the given width the remaining tooltip text will be displayed in the next line, instead of displaying the whole text in single line.

 Signature 

Pratik Agrawal

3 replies

September 27, 2011

Andre Andre
Robot Herder
6394 posts

So… you want to prevent a line break?

First of all, notice that long lines of text are hard to read, especially on a screen. I normally find myself manually breaking tooltip texts as they appear too long for my taste.

Then: you can use rich text. You might try to use a <span> element around your non-breaking line.

September 27, 2011

pratik041 pratik041
Lab Rat
346 posts

No, i want the multiple lines but according to width i give. I mean each line should be of the given width.

 Signature 

Pratik Agrawal

September 28, 2011

Volker Volker
Ant Farmer
5428 posts

Maybe this will work:

  1. QString toolTipText =
  2.     "<nobr>A short line</nobr><br/>"
  3.     "<nobr>This is a much longer line than the first</nobr>";

I don’t understand your last comment:

pratik041 wrote:
No, i want the multiple lines but according to width i give. I mean each line should be of the given width.

What do you want to do? Do you want to set the width of the tooltip manually? Sometimes it’s hard to describe something in text, an image with a screenshot of the current situation and a scribble how you want it to look like would be helpful in this case.

 
  ‹‹ QTNetwork proxyAuthenticationRequired fires only "once"      How to control size of widgets of QSplitter container? ››

You must log in to post a reply. Not a member yet? Register here!