QT6 cannot resize layout
-
In QT Designer I have a MainWindow, then I have a centralwidget and in the centralwidget I can put any layout but it will never 'stretch'.
The layout must be hardcoded heigth and width and thereby my entire application is not able to resize.I must say the properties of the layout are all in red and I do not know why, the outline of the layout is also in red and again I do not know why. I have read more than a few tutorials and did not find any resizing application, it seems that fixed height/width is the standard.
Reading the docs and searching Google and SO, it seems that using a layout in the centralwidget should work and widgets should resize within that, there I can set policies for the priority and direction of resizing etc, all lovely if the layout would work.What am I missing here?
Also asked here on SO: https://stackoverflow.com/questions/74199142/stretching-grid-with-widgets
# -*- coding: utf-8 -*- ################################################################################ ## Form generated from reading UI file 'thijs2.ui' ## ## Created by: Qt User Interface Compiler version 6.4.0 ## ## WARNING! All changes made in this file will be lost when recompiling UI file! ################################################################################ from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, QMetaObject, QObject, QPoint, QRect, QSize, QTime, QUrl, Qt) from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QGradient, QIcon, QImage, QKeySequence, QLinearGradient, QPainter, QPalette, QPixmap, QRadialGradient, QTransform) from PySide6.QtWidgets import (QApplication, QFrame, QHBoxLayout, QMainWindow, QMenuBar, QSizePolicy, QStatusBar, QTextEdit, QWidget) class Ui_MainWindow(object): def setupUi(self, MainWindow): if not MainWindow.objectName(): MainWindow.setObjectName(u"MainWindow") MainWindow.resize(800, 600) self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName(u"centralwidget") sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth()) self.centralwidget.setSizePolicy(sizePolicy) self.horizontalFrame = QFrame(self.centralwidget) self.horizontalFrame.setObjectName(u"horizontalFrame") self.horizontalFrame.setGeometry(QRect(259, 228, 231, 241)) sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth(self.horizontalFrame.sizePolicy().hasHeightForWidth()) self.horizontalFrame.setSizePolicy(sizePolicy1) self.horizontalLayout = QHBoxLayout(self.horizontalFrame) self.horizontalLayout.setObjectName(u"horizontalLayout") self.textEdit = QTextEdit(self.horizontalFrame) self.textEdit.setObjectName(u"textEdit") self.horizontalLayout.addWidget(self.textEdit) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(MainWindow) self.menubar.setObjectName(u"menubar") self.menubar.setGeometry(QRect(0, 0, 800, 30)) MainWindow.setMenuBar(self.menubar) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName(u"statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QMetaObject.connectSlotsByName(MainWindow) # setupUi def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None)) # retranslateUi
-
@Thijs-0 said in QT6 cannot resize layout:
in the centralwidget I can put any layout but it will never 'stretch'.
Because you need to apply a layout to the central widget. You can right click in an empty space in your main window (center widget) and select a layout using "Lay out".