Khandakhulu
Khandakhulu

Reputation: 371

Changing the central widget to vertical layout

I am using Qt Creator 4.14.0 running on a Windows 10 machine. I have created my first application by selecting File ->New File or Project -> Application Qt -> Qt Widgets Application. When I open up MainWindow.ui which activates the graphical editor, I right click on central widget so that I can set the layout to vertical. That's what the book I am using instructs. But on doing so, there is no option for changing the layout.

How does one use the editor to set the layout on the central widget?

Upvotes: 1

Views: 1380

Answers (2)

Manuninho
Manuninho

Reputation: 31

What I got to achieve that was:

Add to the centralwidget an Horizontal Layout, and morph it to QWidget. After a normal build (so the moc files will be updated with the new generated code by the ui) you'll have access to 2 new variables: The QHBoxLayout and the (new horizontal) QWidget.

After that you can access in a similar way, but instead to use:
ui->centralwidget
you could now use:
ui->horizontalWidget

It's kind of a workaround for me right now.

Upvotes: 0

SajadBlog
SajadBlog

Reputation: 585

while there is no widget in a widget you can not set the layout from the designer. immediately after your add the first widget, the layout button will be enabled. and after setting the layout you can remove the added widget and have an empty mainwindow with the layout.

Upvotes: 2

Related Questions