I create a simple UI with Qt Designer and convert it to Python codes. I searched for any method to detect changing window size.
This is the generated code :
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def onResize(event):
print(event)
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setWindowTitle("MainWindow")
MainWindow.resize(200, 200)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
MainWindow.setCentralWidget(self.centralwidget)
MainWindow.resized.connect(self.someFunction)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
I found a similar question QWidget resize signal? and this tutorial to handle size that recommended overriding resizeEvent method of QMainWindow.
But any of them doesn't solve my problem. Is there any resized function to detect window resizing like below:
MainWindow.resized.connect(self.someFunction)