I'm using python3 and pyqt4 and I want some code to run every time my QMainWindow
is resized.I would like something like this
self.window.resized.connect(self.resize)
but resized
is not a builtin function or method.
Can anyone help.
You must override the resizeEvent
method.
from PyQt4 import QtCore, QtGui
import sys
class MainWindow(QtGui.QMainWindow):
def resizeEvent(self, event):
print("resize")
QtGui.QMainWindow.resizeEvent(self, event)
app = QtGui.QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec_())