1
如何連接到關閉QTextEdit窗口小部件的函數?在PyQt中關閉QTextEdit時連接到方法/函數
我的代碼:
self.textBox = QtGui.QTextEdit()
self.textBox.setWindowTitle('Editor')
self.textBox.setGeometry(100, 100, 1000, 500)
self.textBox.show()
self.textBox.???.connect(self.someFunc) #????
如果我做
self.textBox.close().connect(self.someFunc)
它立即關閉,並說
AttributeError: 'bool' object has no attribute 'connect'
如果我做
self.textBox.closeEvent(self.someFunc)
它說
TypeError: QTextEdit.closeEvent(self.someFunc): argument 1 has unexpected type 'method'
我該如何解決這個問題?
你的意思是什麼行動,關閉? – eyllanesc
或者你的意思是關閉包含它的小部件? – eyllanesc
這是一個文本編輯器,我實現了,並從我的菜單欄在主窗口中打開,它像一個新窗口打開,所以當編輯器打開並在窗口中輸入某些內容時,關閉編輯器(QTextEdit)窗口,我需要關閉事件連接到一個功能。 – learncode