python培训之PyQt信号和插槽的连接

发布时间:2022-12-17 09:51:39 人气:66 作者:多测师

  python PyQt信号和插槽的连接

  1、为了让菜单选项和工具栏在用户点击它们时启动,需要将信号与内置插槽连接起来。

  2、QAction物体可以发出各种信号。triggered()与插槽连接。

  菜单和工具栏中最常用的信号是.triggered()。用户每次点击菜单选项或工具栏按钮都会发出这个信号。

  实例

  class Window(QMainWindow):

  # Snip...

  def newFile(self):

  # Logic for creating a new file goes here...

  self.centralWidget.setText("File > New clicked")

python培训之PyQt信号和插槽的连接

  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学习指路:请关注多测师。https://www.e70w.com/xwzx/


返回列表
在线客服
联系方式

热线电话

17727591462

上班时间

周一到周五

二维码
线