James
James

Reputation: 3752

Hiding a QWidget on a QToolbar?

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!

Upvotes: 21

Views: 5222

Answers (1)

richardwb
richardwb

Reputation: 4539

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

QAction* widgetAction = toolBar->addWidget(someWidget);
widgetAction->setVisible(false);

Upvotes: 36

Related Questions