[Qt-interest] tooltips
phil prentice
philp.cheer at talktalk.net
Tue Oct 26 14:21:59 CEST 2010
Hi
My application uses the status bar(by default) to display tooltips. I would
very much like to be able to display the tooltips somewhere differently e.g
maybe in widget (text entry or whatever). I looked at the tooltips example
and thought that perhaps I could over-ride the application event handler and
do something with that i.e.
bool VIwindow::event(QEvent *event) // virtual
{
if (event->type() == QEvent::ToolTip)
{
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
/*
int index = itemAt(helpEvent->pos());
if (index != -1)
QToolTip::showText(helpEvent->globalPos(), shapeItems[index].toolTip());
else
QToolTip::showText(helpEvent->globalPos(), "");
*/
qDebug("XXXX");
}
return QWidget::event(event);
}
I presume that I would have to search every widget in the application (using
childAt())??? to locate the appropriate widget and grab the tooltip? This
could be quite slow??? I have several hundred widgets in my application.
Is this a feasable idea???
Alternatively I guess that I could sub-class all of the standard widgets in
my application and override the event class for that widget to handle its
objects tooltips? Could be a lot of work?
Is there a better way to achieve what I would like to do?
Thanks again
Any help appreciated
Phil
More information about the Qt-interest-old
mailing list