QtPy5 获取lineEdit里的数值

代码片段如下:

def setupUi(self, MainWindow):
      self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
      self.lineEdit.setGeometry(QtCore.QRect(290, 220, 201, 31))
      
      #确认按钮
      self.sure_Button = QtWidgets.QPushButton(self.centralwidget)
      self.sure_Button.setGeometry(QtCore.QRect(150, 470, 93, 28))
      self.sure_Button.clicked.connect(self.addNum)
     
def addNum(self):
      #这里获取的是String,不是什么QString
      s = self.lineEdit.text()
      #不能用 interval = s.toInt()
      interval = int(s)
     

你可能感兴趣的:(Python)