Jake Jake -4 years ago 70
C++ Question

How to change UI without opening a new window in Qt?

In my program, I'm moving from

on a press of a button.

I want to do the same without opening a new window and be able to move between the UI's.

The Target device will have a very small touchscreen, so I want my UI to sit still and require minimal repositioning.

Please point me in the right direction or give me an example on How-to.

Answer Source

To do that, you can use a QStackedWidget.
From the documentation:

The QStackedWidget class provides a stack of widgets where only one widget is visible at a time.

Instead of opening a new window, push its content on top of the stack and pop it when you want to (let me say) close the window.
Each widget is a page of your application and no separate window is required. You can design them as you would design a central widget of a normal window or dialog.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download