我正在尝试为几个动态添加到 QMainWindow 的 dockWidgets 捕获 closeEvent。我不清楚如何确定哪个小部件已关闭。这是一个简化的示例:
class Example(QtGui.QMainWindow):
def __init__(self):
super(Example, self).__init__()
self.leftDockWidget = QtGui.QDockWidget('pick tool', self)
self.leftDockWidget.setWidget( QtGui.QLabel('a dock widget') )
self.addDockWidget( QtCore.Qt.LeftDockWidgetArea, self.leftDockWidget )
self.leftDockWidget.closeEvent = self.dockWidgetCloseEvent
self.show()
def dockWidgetCloseEvent(self, event):
print event
# how to get sender widget ?
event.sender() 似乎不存在..有什么想法吗?
谢谢