Miky Mike
Miky Mike

Reputation: 341

How to Remove a widget from a QToolBar?

I'm building my App interface with Qt at the moment. But one question arises... I have a QToolbar to which I added a QToolButton with the QToolbar->addWidget method. The problem is that I want to remove this button later on.

How can I achieve that ?

There is an addWidget method but nothing like a removeWidget correspondence...

Any idea ?

Thanks a lot in advance for your help.

Miky Mike

Upvotes: 3

Views: 6042

Answers (1)

TonyK
TonyK

Reputation: 17114

You have to use removeAction. Like this:

QAction* MyAction = MyToolBar -> addWidget (MyWidget) ;
...
MyToolBar -> removeAction (MyAction) ;

Upvotes: 7

Related Questions