McLan
McLan

Reputation: 2678

QT-Creator: How to align center my QWidgets when in full screen?

I know how to set my application to start in full screen by settin gthe following in the main.cpp:

MainWindow w;
w.setWindowState(Qt::WindowMaximized);
w.show();

However, when in full-screen, all my widgets goes into the left-top corner.

How to centralized my widgets when in full screen ?! and alike when minimizing the screen to normal size ?!

(a tutorial will be much helpful too)

Upvotes: 0

Views: 3427

Answers (2)

Konrad 'Zegis'
Konrad 'Zegis'

Reputation: 16501

Qt - by default - doesn't do anything with window contents when you re-size it. All widgets'll be exactly the same size as were before, so behavior you describes is perfectly fine. To force window contents to adjust position and size of your widgets you must associate Layout Manager with container.

The easiest way to do it is to fire up Qt Creator and open desired window with UI desinger. Then right click on the container you want to associate Layout Manager and use layout item from context menu.

I thing those article and examples should help you.

Upvotes: 1

CJCombrink
CJCombrink

Reputation: 3950

You need to use layouts when designing your GUIs.

You can look at the Layout Management page on the Qt documentaion.

Also the following video on layouts might be helpful.

Upvotes: 1

Related Questions