PDA

View Full Version : Turning off ToolTips



steg90
16th May 2007, 15:04
Hi,

Is it possible to turn off tooltips for certain widgets? Reason is, I have a custom tooltip which is not displaying and just wondered if it is because of the 'built-in' ones?

Regards,
Steve

marcel
16th May 2007, 15:12
How did you set the custom tool tip?

steg90
16th May 2007, 15:17
Hi Marcel,

I was going to try use a delegate which would then display a custom tooltip. The tooltip I was going to use was from CVXPTooltipManager class ( http://www.tooltips.net) but unfortunately it isn't going to work, it is mainly catered for MFC/ATL apps.

Is it possible to code your own tooltip widget?

Regards,
Steve

marcel
16th May 2007, 15:20
Of course, you could create some custom widget which you can show. You could do custom painting in paintEvent();
But make sure to set the Qt::Tooltip flag when you create it.

Regards

jpn
16th May 2007, 15:22
Catch QEvent::TooplTip to show custom tooltips. See Tooltips Example (http://doc.trolltech.com/4.2/widgets-tooltips.html).

steg90
16th May 2007, 15:27
Thanks Marcel,

Being quite new to Qt, I'm not sure how to do this yet?:confused: . I guess I derive from QWidget, obviously override the paintEvent, mouseMoveEvent and mousePressEvent. Even if I did the custom tooltip, I still unsure how to connect it to my tableview, my thought was to not use the default delegate for the Qt::ToolTipRole and use my own?

Regards,
Steve

marcel
16th May 2007, 15:33
Correct! All you need to do is override paintEvent.
Setting Qt::Tooltip will take care of the rest.

steg90
16th May 2007, 15:35
Thanks again,

How do I set Qt::Tooltip?

Regards,
Steve

marcel
16th May 2007, 15:42
When you create the widget. The first parameter is the parent, the second is the window flags. It is an OR-ed combination of window flags.

See Qt::WindowFlags

Teerayoot
16th May 2007, 15:58
Qt already support html tooltip,tranparent ,that make very customize look and feel.
If it not enough you even can custom draw ,in simple subclass painEvent.

I think no need to use third party tooltip.

steg90
16th May 2007, 16:08
What about using bool QAbstractItemView::viewportEvent ( QEvent * event ) in my TableView? I guess I could write a class which derives from QTableView and override this event?

Regards,
Steve

jpn
16th May 2007, 17:00
What about using bool QAbstractItemView::viewportEvent ( QEvent * event ) in my TableView? I guess I could write a class which derives from QTableView and override this event
Yes, that's the correct place (and also where QAbstractItemView implements the default tooltip behaviour). Just be sure to pass all others but the interesting tooltip events to the base class implementation. ;)