PyQt: RuntimeError: wrapped C/C++ object has been deleted

后端 未结 4 1730
醉酒成梦
醉酒成梦 2020-12-01 18:25

If I run this code:

    #!/usr/local/bin/    python3

import sys 
from PyQt4.QtCore import *
from PyQt4.QtGui import *


class Window(QMainWindow):

    def          


        
4条回答
  •  悲哀的现实
    2020-12-01 18:39

    This answer to this question is as found here: Python PySide (Internal c++ Object Already Deleted)

    Apparently, assigning one widget to QMainWindow using setCentralWidget and then assigning another widget with setCentralWidget will cause the underlying c++ QWidget to be deleted, even though I have an object that maintains reference to it.

    Note: QMainWindow takes ownership of the widget pointer and deletes it at the appropriate time.

提交回复
热议问题