This works...
QToolButton * toolbutton = new QToolButton(this);
//hide before addWidget
toolbutton->hide();
addWidget(toolbutton);
But this doesn't
QToolButton * toolbutton = new QToolButton(this)
addWidget(toolbutton);
//hide after addWidget
toolbutton->hide();
Is there an alternative so I can actually hide after a QToolButton after it is added to a QToolBar? I need to during runtime.
QAction * QToolBar::addWidget ( QWidget * widget )
You should hide returned QAction
One alternative is to add a QAction instead of a widget and then hide the QAction. I've tried it and it works with QAction::setVisible(false).
You can also do something like QToolBar::actions().at(3)->setVisible(false); if you know the position of the widget in the QToolBar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With