alex simon
alex simon

Reputation: 71

How to activate centralWidget in QT Designer

I was looking at this article How to make a Qt Widget grow with the window size? but when i got to the answer I got stuck on "activating" the central widget. I notice an icon with a red circle so I guess that means its disabled. I've been searching the net to try to figure out how to "activate" it but I am not having any luck.

Can someone please help me out?

Upvotes: 7

Views: 10304

Answers (2)

SerNik89
SerNik89

Reputation: 11

To fix the error you can open file mainwindow.ui in external editor program. Then change tag string:

<widget class="QWidget" name="centralwidget"/>

to:

<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="centralHLayout">
</layout>
</widget>

Then you can continue to work in Qt Designer: the centralWidget icon will not have the red circle and you can append any layouts and widgets to centralWidget that will be stratched by stratching main window.

Upvotes: 0

Nox
Nox

Reputation: 932

Have a look at the layout system. That icon does not mean your QWidget is disabled, that just mean you do not apply a layout on it. Try to press like Ctrl+1 in order to apply a basic layout. If nothing has changed, you might need to put a QWidget inside the central widget first and then apply the layout.

Upvotes: 6

Related Questions