I added a QAction
on a QToolBar
, but I can't remove a tooltip from the button.
I tried to overide event
, eventfilter
using event->type == Qt::Tooltip
but it didn't help.
Please help me.
I added a QAction
on a QToolBar
, but I can't remove a tooltip from the button.
I tried to overide event
, eventfilter
using event->type == Qt::Tooltip
but it didn't help.
Please help me.
Copyright © 2021 Jogjafile Inc.
Why it happens
When you add an action on a toolbar:
QToolButton
QToolButton::setDefaultAction
passing the action as an argument.setToolTip(action->toolTip());
action->toolTip()
returns whethertooltip
or if the tooltip is empty it returnstext
. Thus you'll always have some tooltip on the button.What to do
Using the explanation above you can think of lots of ways to solve the problem.
For example, when
QToolbar
is created (and possibly shown) usetoolbar->findChildren<QToolButton*>
to find the buttons:Note: when you change a text of an action, the appropriate button will recreate the tooltip. You can use an event filter for a button to process the tooltip event.
EDIT: added an example:
Ui
contains a toolbar with an action.When you change an action (text, enabling state...) a
QToolButton
updates a tooltip. In this case you need to prevent the tooltip appearance permanently: