saurabhsood91
saurabhsood91

Reputation: 489

Dynamic user interfaces in Qt

I have a button, and a layout, which loads a custom QWidget. I want to change the widget in the layout into another sample widget when clicking a button. The previous widget should be completely replaced by the new widget. How could I achieve such an effect?

Source Code: http://paste.opensuse.org/51831462

Upvotes: 0

Views: 141

Answers (2)

Synxis
Synxis

Reputation: 9388

QStackedWidget is perfect for what you want to achieve.

You will have to redesign a bit your code, but the result will be simpler to understand and to maintain. You just have to change the current widget of the QStackedWidget when the button is clicked.

Upvotes: 2

Wouter
Wouter

Reputation: 670

You could try with setCentralWidget(). Could you include your source code in your question?

Upvotes: 0

Related Questions