Python PySide (Internal c++ Object Already Deleted)

后端 未结 2 1560
耶瑟儿~
耶瑟儿~ 2021-01-03 22:07

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

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-03 22:43

    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

提交回复
热议问题