PDA

View Full Version : enable all Tooltips



clive
1st January 2008, 23:55
Is it possible to turn all tool tips on and off globally in an application?
If so how?

aamer4yu
2nd January 2008, 06:10
am not sure if it possible.
But you can try catching the tooltip event in QWidget::event using QEvent::ToolTip, and ignore the event.
hope this helps :)

jpn
2nd January 2008, 07:34
Furthermore, installing an event filter (http://doc.trolltech.com/latest/qobject.html#eventFilter) on the application object gives you access to all events of the whole application. Notice also Qt::WA_AlwaysShowToolTips (http://doc.trolltech.com/latest/qt.html#WidgetAttribute-enum).

clive
2nd January 2008, 11:08
Thanks....

For future reference for others this is what I did.

I add this function to my app...


bool MainWin::eventFilter(QObject *obj, QEvent *event)
{
if(cbToolTips->isChecked() == true)
{
if (event->type() == QEvent::ToolTip)
{
return true;
}
else
{
return QMainWindow::eventFilter(obj, event);
}
}
else
{
return QMainWindow::eventFilter(obj, event);
}
}

Note I am using a CheckBox to determine if tool tips need to be disabled.

In the header file I add this..


protected:
bool eventFilter(QObject *obj, QEvent *ev);


Then I install the filter like this


qApp->installEventFilter(this);


I hope this helps others.