我有igui,我想在两个类之间建立一些通信
.
.
.
mainWidget = QtGui.QWidget()
mainWidget.setLayout( mainLayout )
self.setCentralWidget( mainWidget )
self.show()
""" Creating class """
self.server = MCCommunication.MCCommunication()
self.connect( self.server, QtCore.SIGNAL( "textUpdated" ), self.insertText );
sys.exit( self.app.exec_() )
MCCommunication类如下:
类通信(QtCore.QObject): ''' 类文档 '''
^{pr2}$但我得到了以下错误:
self.emit( QtCore.SIGNAL( "textUpdated" ), ( "TCPServer listening on" ) )
RuntimeError: underlying C/C++ object has been deleted
我不使用老式的Signal和slot语法。
您可以使用新样式:
在GUI实例中:
^{pr2}$更新:我添加了斯蒂芬特里的建议。在
p.S.(“TCPServer监听”)不是元组。它没有逗号。
(“TCPServer监听”,)是一个单元素元组。在
您需要初始化MCCommunication类中的底层QObject。将此行添加到
__init__
方法的开头:相关问题 更多 >
编程相关推荐