Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to activate centralWidget in QT Designer

Tags:

c++

qt

qtwidgets

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?

like image 379
alex simon Avatar asked Dec 17 '14 23:12

alex simon


People also ask

What is Centralwidget in Qt?

The centralwidget refers to a relative position but it is not exactly a central position: #include <QtWidgets> int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow w; QLabel *central_widget = new QLabel("Central Widget"); central_widget->setAlignment(Qt::AlignCenter); w.

How do I add widgets to Qt?

To add widgets in Qt Designer: In the Qt Creator Edit mode, double-click the notepad. ui file in the Projects view to launch the file in the integrated Qt Designer. Drag and drop widgets Text Edit (QTextEdit) to the form.

How do I add a layout to QMainWindow?

Add at least one widget on your MainWindow . Then select your window by clicking on it and click on the VerticalLayout Button at the top of QTCreator . You Vertical Layout is automatically added to the central widget and fills all the surface.


1 Answers

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.

like image 172
Nox Avatar answered Oct 10 '22 06:10

Nox