Hi all
Working on Qt4.2 for MAC
Can any body tells me that , How can The tooltip for the button should be shown in some Image say "balloon".
Thanx
Hi all
Working on Qt4.2 for MAC
Can any body tells me that , How can The tooltip for the button should be shown in some Image say "balloon".
Thanx
Always Believe in Urself![]()
Merry
Hi....
I mean How can I display the tooltip for the QPushbutton in an image
image can be of anytype
1. Circle
2. balloon
3. triangle etc .....
Thanx
Always Believe in Urself![]()
Merry
So you want to display an image with a QToolTip.
Should be easy enough if you subclass QToolTip and override its paintEvent.
The image, for example the triangle should contain the triangle in a specific color and the rest has to be a color different from the one the triangle has.
This is to be able to create a heuristic mask (make the image transparent around the triangle ).
Qt Code:
QPixmap tipPix; //.. load the pixmap tipPix.setMask(tipPix.createHeuristicMask());To copy to clipboard, switch view to plain text mode
Another solution is to use a transparent png.
Regards
Thanx 4 the sol.
But I dont want to display an image with the tooltip . I want to display toolTip (Text) in the balloon image....
for eg.
If I set the tooltip for the button ... It is drawn immediately below the given position in a distinctive black-on-yellow color combination in a rectangle, right , Now Instead of that rectangle I want to use balloon.
Thanx
Always Believe in Urself![]()
Merry
Yes, for that you will have to use custom drawing.
Tool tips are platform dependent. So on windows they actually look like a balloon.
If you want them to look like that on Mac, then you have to paint them yourself. Either by using images, or drawing primitives, whatever.
Since you are on a Mac, you could take advantage of the desktop composition features and add some need effects to it, like transparent gradations, etc.
Regards
merry (1st August 2007)
THANX 4 the soln.
But I dont know how to do custom drawing...
Can u Explain me it with example
thanx
Always Believe in Urself![]()
Merry
Ok I 'll draw it using images and drawing primitives ..
but how can i set it for the tooltip , so that tooltip should be displyed in that balloon.
Always Believe in Urself![]()
Merry
Custom drawing is not that hard in general, but this tooltip problem will be pretty hard to solve.
First of all, you have to subclass the event() function for the widget you want the tip to appear.
In the event function you will look for a QHelpEvent, whose type is QEvent::ToolTip. This means that the widget is requested to show a tool tip.
The second step is to subclass QToolTip and override the paintEvent. In paintEvent you do all the drawing.
mCustomToolTip should be a member of your widget's class, which you initialize to NULL in the constructor.Qt Code:
{ { if(!mCustomToolTip) mCustomToolTip = new CustomToolTip(this); mCustomToolTip->show(); e->accept(); return true; } else { if(mCustomToolTip) mCustomToolTip->hide(); } }To copy to clipboard, switch view to plain text mode
For the paintEvent:
Qt Code:
void CustomToolTip::paintEvent() { p.fillRect(rect(), Qt::transparent ); p.setBrush(Qt::red); p.drawEllipse(rect()); }To copy to clipboard, switch view to plain text mode
This draws a red ellipse on a transparent background.
It is just an example. You could customize the drawing further.
Regards
Thanx 4 the solution
Ok I ' ll try the solution.....
Always Believe in Urself![]()
Merry
Hi Marcel
Pls Explain the above line...mCustomToolTip should be a member of your widget's class, which you initialize to NULL in the constructor.
Is it the member of the Subclass QToolTip.
Thanx
Always Believe in Urself![]()
Merry
No.
Let's assume that you want the custom tooltip be displayed for a button.
Then you need to subclass QPushButton and override its event() function, where you put the code I've shown you earlier.
The custom tooltip should be a member of this subclass.
BTW, for what widget(s) you want a custom tooltip to be displayed?
Regards
Hi...
Qt Code:
if(!mCustomToolTip) mCustomToolTip = new CustomToolTip(this); mCustomToolTip->show();To copy to clipboard, switch view to plain text mode
but in the above code u sent to me , Custom ToolTip is the SubClass Of QToolTip ..
but now u said that the custom tooltip should be a member of QPushbutton subclass.
Pls once again u view the code u sent to me and Explain it to me
Thanx
Always Believe in Urself![]()
Merry
Bookmarks