先看效果:
import sys
from PyQt5.QtWidgets import QWidget,QApplication
from PyQt5.QtCore import pyqtSlot
from Price import Ui_Form
class PriceMain(QWidget):
def __init__(self,parent = None):
super().__init__(parent)
self.ui = Ui_Form()
self.ui.setupUi(self)
def on_pushButtonTatol_clicked(self):
num = int(self.ui.lineEditNum.text())
price = float(self.ui.lineEditPrice.text())
self.ui.lineEditTatol.setText("%.2f"%(num*price))
@pyqtSlot(int)
def on_spinBox_valueChanged(self,count):
price = int(self.ui.lineEditPrice2.text())
self.ui.lineEditTatol_2.setText("%.2f"%(count*price))
if __name__ == "__main__":
app = QApplication(sys.argv)
wgt = PriceMain()
wgt.show()
sys.exit(app.exec_())
对于具有overload型参数的信号,只为其中的一种参数形式的信号生成槽函数时,如果不是默认参数类型,应该使用@pyqtSlot修饰符声明参数类型
aaa