tags:

views:

158

answers:

1

Hi,

I have directly added some QWidgets to a QToolbar but simply going widget->setVisible(false) did not work. Can someone please give me an example of how to show and hide a widget that is on a QToolbar?

Thanks!

+3  A: 

You need to call setVisible() on the appropriate QAction instead. For example, addWidget() returns a QAction*:

QAction* widgetAction = toolBar->addWidget(someWidget);
widgetAction->setVisible(false);
richardwb
Thanks, didn't notice it returned a QAction on the addWidget! So much for knowing how to read simple API docs.
James