I recently decided to write my first app with Python and PySide. But I have a problem and hope you guys can help.
Python keeps raising exceptions that the \"Internal
After some searching and hair pulling, I found the solution. I was showing all the pages by setting them as the central widget, and when reading the QMainWindow documentation I found that my widget basically gets deleted by qt as stated:
Note: QMainWindow takes ownership of the widget pointer and deletes it at the appropriate time.
So to develop a Multi-Page application rather take a look at QStackedWidget.
See here: PySide Pitfalls.
If a QObject falls out of scope in Python, it will get deleted. You have to take care of keeping a reference to the object:
- Store it as an attribute of an object you keep around, e.g. self.window = QMainWindow()
- Pass a parent QObject to the object’s constructor, so it gets owned by the parent