I am trying to set tooltip display width with the following code but i am not getting the exact output?
-
wrote on 12 Jan 2012, 11:48 last edited by
@ wid.setStyleSheet("QToolTip {font-size:12pt; color:white; border-width:2px; border-style:solid; width: 10px;}");@
What is the error in the above code? -
wrote on 12 Jan 2012, 12:19 last edited by
http://developer.qt.nokia.com/doc/qt-4.8/stylesheet-reference.html search width.
@wid.setStyleSheet("QToolTip {font-size:12pt; color:white; border 2px solid black; min-width: 10px;}");@
-
wrote on 12 Jan 2012, 12:36 last edited by
[quote author="pratik041" date="1326368889"]@ wid.setStyleSheet("QToolTip {font-size:12pt; color:white; border-width:2px; border-style:solid; width: 10px;}");@
What is the error in the above code?[/quote]Well - that's the question: what is the error in the code above.
So, what is the error in the code above? Which result do you expect? Which result do you get instead?
-
wrote on 12 Jan 2012, 12:37 last edited by
i have tried this i am now getting the require width but another problem is their the tooltip text
is not visible.
i have used the following
@wid.setStyleSheet("QToolTip {font-size:12pt; color:white; border 2px solid black; min-width: 10px;}");
wid.settooltip("text");@ -
wrote on 12 Jan 2012, 12:43 last edited by
[quote author="Lukas Geyer" date="1326371764"][quote author="pratik041" date="1326368889"]@ wid.setStyleSheet("QToolTip {font-size:12pt; color:white; border-width:2px; border-style:solid; width: 10px;}");@
What is the error in the above code?[/quote]Well - that's the question: what is the error in the code above.
So, what is the error in the code above? Which result do you expect? Which result do you get instead?[/quote]
First thing is i want to set tooltip display rect to given width like if i set 40px width if the tooltip text exceeds the 40px it should display in the next line.
Secondly the error is i am not getting the width i set and the tooltip is also not showing only the blank tooltip rect is coming. -
wrote on 12 Jan 2012, 12:43 last edited by
@QToolTip {
font-size:12pt;
color:white; --- Font color ----<<<< Attention!! use (pseudo code) background: ~white or color: ~white
border 2px solid black; --- border width, style, color
min-width: 10px;
@ -
wrote on 12 Jan 2012, 13:14 last edited by
[quote author="stima_ua" date="1326372218"]@QToolTip {
font-size:12pt;
color:white; --- Font color ----<<<< Attention!! use (pseudo code) background: ~white or color: ~white
border 2px solid black; --- border width, style, color
min-width: 10px;
@[/quote]but setting pseduo code the tooltip is displaying but width portion is not working i am using "max-width" instead of "min-width".
-
wrote on 12 Jan 2012, 13:25 last edited by
@QString text = "Some text: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"@ --- its 1 line
You want:
.
| Some text: aaaa |
.
| aaaaaaaaaaaaaa |You need:
(pseudo code)@if ( text.size() > mySize ) {
text.insert(mySize, "\n")
}@Something like this.
-
wrote on 12 Jan 2012, 13:43 last edited by
[quote author="stima_ua" date="1326374757"]@QString text = "Some text: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"@ --- its 1 line
You want:
.
| Some text: aaaa |
.
| aaaaaaaaaaaaaa |You need:
(pseudo code)@if ( text.size() > mySize ) {
text.insert(mySize, "\n")
}@Something like this.[/quote]
ya i want like this. Is it possible through stylesheet?
I can do this by inserting "\n" in the tooltip string but the problem is that i want to break string according to pixels width.Do you have any way for doing this? -
wrote on 12 Jan 2012, 13:52 last edited by
hm...i think its possible, but i dont know how((;
p.s. If you find solution post him plz
p.s.s. mb use QTextLayout ... sorry but i have not time to test))
-
wrote on 12 Jan 2012, 13:59 last edited by
[quote author="stima_ua" date="1326376375"]hm...i think its possible, but i dont know how((;
p.s. If you find solution post him plz[/quote]
I have tried using QfontMetrices . Here i am able to find the total text pixel size but i don't able to find how to break it according to pixels size.
-
wrote on 12 Jan 2012, 22:02 last edited by
After reading this post, I checked Qt doc and found.
bq. Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <p >.
Hmm.. if your text is not wrapped, what was the problem then? wierd.
-
wrote on 13 Jan 2012, 04:44 last edited by
[quote author="joonhwan" date="1326405736"]After reading this post, I checked Qt doc and found.
bq. Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <p >.
Hmm.. if your text is not wrapped, what was the problem then? wierd.[/quote]
I want to write a function where i will provide required text width in pixels and that function will set the tooltip display width to specified pixels width and the line exceeding it will be come to the next line.Can you say me what useful information you found in the doc related to this and How can i use that to achieve this with some example?
4/13