新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python PyQt信號和插槽的連接
1、為了讓菜單選項和工具欄在用戶點擊它們時啟動,需要將信號與內(nèi)置插槽連接起來。

2、QAction物體可以發(fā)出各種信號。triggered()與插槽連接。
菜單和工具欄中最常用的信號是.triggered()。用戶每次點擊菜單選項或工具欄按鈕都會發(fā)出這個信號。
實例
class Window(QMainWindow):
# Snip...
def newFile(self):
# Logic for creating a new file goes here...
self.centralWidget.setText("File > New clicked")
def openFile(self):
# Logic for opening an existing file goes here...
self.centralWidget.setText("File > Open... clicked")
def saveFile(self):
# Logic for saving a file goes here...
self.centralWidget.setText("File > Save clicked")
def copyContent(self):
# Logic for copying content goes here...
self.centralWidget.setText("Edit > Copy clicked")
def pasteContent(self):
# Logic for pasting content goes here...
self.centralWidget.setText("Edit > Paste clicked")
def cutContent(self):
# Logic for cutting content goes here...
self.centralWidget.setText("Edit > Cut clicked")
def helpContent(self):
# Logic for launching help goes here...
self.centralWidget.setText("Help > Help Content... clicked")
def about(self):
# Logic for showing an about dialog content goes here...
self.centralWidget.setText("Help > About... clicked")以上就是python PyQt信號和插槽的連接方法,希望對大家有所幫助。更多Python學(xué)習(xí)指路:創(chuàng)新互聯(lián)python教程
本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。
文章名稱:創(chuàng)新互聯(lián)Python教程:python PyQt信號和插槽的連接
本文URL:http://fisionsoft.com.cn/article/dhipooo.html


咨詢
建站咨詢
