Reputation: 5521
Is it possible to change the time delay between the mouse being still in a window, and the tooltip's show event?
Is there a Qt wrapper for something like TTM_SETDELAYTIME
? According to the Windows documentation, the default value depends on the double-click interval.
Upvotes: 4
Views: 1640
Reputation: 4367
You'll have to set a custom QProxyStyle
that overrides styleHint()
and returns your preferred value for QStyle::SH_ToolTip_WakeUpDelay
. Sample code below.
class CustomStyle : public QProxyStyle
{
Q_OBJECT
\\...
public:
int styleHint(StyleHint hint, const QStyleOption *option = nullptr,
const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override
{
if (hint == SH_ToolTip_WakeUpDelay)
return someCustomValue;
else
return QProxyStyle::styleHint(hint, option, widget, returnData);
}
}
Upvotes: 6
Reputation: 5521
Apparently that's not possible with the built-in Qt Tooltips. In 4.8 qapplication.cpp
they use magic numbers:
d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive()?20:700, this);
So the default behavior is to show a tooltip after 700 ms, and start a 2000 ms fall-asleep timer. If we hover over another window(widget) with the fall-asleep timer still active, the delay will be reduced to 20 ms, probably under the assumption that the first tooltip was not the one the user wanted.
Upvotes: 1