pyqt5:Button的信号槽处理机制

模板如下:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super(Ui_MainWindow,self).__init__()
        self.setupUi(self)
        self.retranslateUi(self)
        self.set_myUi()
    def setupUi(self, MainWindow):
		根据自己的界面,使用PYUIC会自动生成这个函数
    def set_myUi(self):
        # 这里的start_btn是你要点击的Button名字(ui里确定了),pushButton_start是触发函数
        self.start_btn.clicked.connect(self.pushButton_start)
    def pushButton_start(self):
		# 根据需求,个性化选择后续操作

参考:https://blog.csdn.net/qq_38113006/article/details/119598504

你可能感兴趣的:(pyqt5,qt,开发语言)