Show Tooltip immediatly

  • I have some QToolBars with QActions in it. Each one has a Tooltip, but i dont like it, that it takes time the Tooltip shows. Is there a Possibility to show the Tooltip directly, if i enter the Widget?

  • The Qt Tool Tips Example could help

  • Slowly i think its not possible. Thanks for your Help, but all the Examples are similar to the setToolTip Method. You can set ToolTips on different Elements/Widgets.

    Its strange. When the Application is started and the Buttons are not hovered something happens in the Background, because if i hover, then it takes some Seconds the Tooltip shows. If i hover from one to another Button then the Tooltip shows directly. But if i leave the Buttons and wait again some Seconds and try to hover again, then i have the Effect again, that it takes some Seconds the Tooltip shows.

  • @Fuel-0 said in Show Tooltip immediatly:

    Slowly i think its not possible

    Actually, there is an uggly workaround which seems to achieve what you want, but has a number of other issues, which may be impractical to resolve:

    In the example below, I created a menu with three QActions, which were also added to the main toolbar (all done in Qt Designer).

    1. Clear the tooltip on each action widget in the toolbar.
      (As per this link:
    2. Install an eventFilter on each button widget of the toolbar.
    3. Connect the hovered signal for each action to a custom showTip() slot
    4. in showTip() , show a QToolTip with the desired text, depending on the action triggered and at the location corresponding to the toolbar button.
    MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::MainWindow)
        foreach (QToolButton* button, ui->mainToolBar->findChildren<QToolButton*>())
        connect(ui->actiontest1, SIGNAL(hovered()), this, SLOT(showTip()));
        connect(ui->actiontest2, SIGNAL(hovered()), this, SLOT(showTip()));
        connect(ui->actiontest3, SIGNAL(hovered()), this, SLOT(showTip()));
    bool MainWindow::eventFilter(QObject* o, QEvent* e)
        if (e->type() == QEvent::ToolTip)
          return true;
        return QMainWindow::eventFilter(o, e);
    void MainWindow::showTip()
        QAction* act = qobject_cast<QAction *>(sender());
        QWidget* widget;
        widget = ui->mainToolBar->widgetForAction(act);
        //To exclude showing tooltip when menu is hovered (tooltip would be at wrong pos)
        if (widget->rect().contains(widget->mapFromGlobal(QCursor::pos())))
            QPoint point = widget->mapToGlobal(QPoint(10,10));
            if (act == ui->actiontest1)
                QToolTip::showText(point, "test1");
            else if (act == ui->actiontest2)
                QToolTip::showText(point, "test2");
            else if (act == ui->actiontest3)
                QToolTip::showText(point, "test3");

    This works in achieving instant tooltip display as soon as the toolbar button is hovered upon, but has several issues:

    1. The tooltip is visible as long as you are hovering over the button
    2. The tooltip is shown even if the Menu is in the drop-down state and hiding the toolbar partially but the cursor happens to be over a (covered) toolbar button.
    3. The tooltips on the corresponding menu must be disabled, otherwise they will be shown at the wrong location (since showTip() will show them at the toolbar button's location).

    In other words, too much hassle to compensate for a small tooltip delay which seems to occur when any other control/application had focus before hovering over the toolbar button.

  • Moderators

    The amount of delay before a tooltip is shown is controlled by the style. You can override it by creating a proxy style like this:

    class MyProxyStyle : public QProxyStyle
        using QProxyStyle::QProxyStyle;
        int styleHint(StyleHint hint, const QStyleOption* option = nullptr, const QWidget* widget = nullptr, QStyleHintReturn* returnData = nullptr) const override
            if (hint == QStyle::SH_ToolTip_WakeUpDelay)
                return 0;
            return QProxyStyle::styleHint(hint, option, widget, returnData);

    This will set the delay to 0 for all widgets. If you want to set the delay only for the toolbar actions you can add an extra condition:

    if (hint == QStyle::SH_ToolTip_WakeUpDelay && widget && widget->inherits(QToolButton::staticMetaObject.className()))

    You set this style for your app like this:

    qApp->setStyle(new MyProxyStyle(qApp->style()));

  • @Chris-Kawa said in Show Tooltip immediatly:

    You can override it by creating a proxy style like this

    Awesome! Thanks!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.