Remove tooltip of QAction when add it to QToolBar in Qt -


i added qaction on qtoolbar, can't remove tooltip button.

i tried overide event, eventfilter using event->type == qt::tooltip didn't help.

please me.

why happens

when add action on toolbar:

  1. it creates qtoolbutton
  2. calls qtoolbutton::setdefaultaction passing action argument.
  3. this method calls settooltip(action->tooltip());
  4. action->tooltip() returns whether tooltip or if tooltip empty returns text. you'll have tooltip on button.

what do

using explanation above can think of lots of ways solve problem.

for example, when qtoolbar created (and possibly shown) use toolbar->findchildren<qtoolbutton*> find buttons:

foreach(qtoolbutton* button, toolbar->findchildren<qtoolbutton*>()) {   button->settooltip(qstring()); } 

note: when change text of action, appropriate button recreate tooltip. can use event filter button process tooltip event.

edit: added example:

ui contains toolbar action.

testwindow::testwindow(qwidget *parent)     : qmainwindow(parent) {     ui.setupui(this);      foreach(qtoolbutton* button, ui.maintoolbar->findchildren<qtoolbutton*>())     {         button->settooltip(qstring());     } } 

when change action (text, enabling state...) qtoolbutton updates tooltip. in case need prevent tooltip appearance permanently:

testwindow::testwindow(qwidget *parent)     : qmainwindow(parent) {     ui.setupui(this);      foreach(qtoolbutton* button, ui.maintoolbar->findchildren<qtoolbutton*>())     {         button->installeventfilter(this);     } }  bool testwindow::eventfilter(qobject* o, qevent* e) {     if (e->type() == qevent::tooltip)     {       return true;     }     return qmainwindow::eventfilter(o, e); } 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -