0

since there isn't any useful How-To for beginners of PyQt5,

I'm stuck with a little problem 。

@pyqtSlot()
def on_pushButton_17_clicked(self):

    """
    Slot documentation goes here.
    """
    A=self.lineEdit_22.text()
    B=self.lineEdit_23.text()
    print(A + B)

Show 12 instead of 3(1+2=3)

I want to enter the number in the lineEdit inside the calculation by PushButton, and get the value.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Zoe.peace
  • 1
  • 1

2 Answers2

1

use float(A) and float(B) for the result

nalayak
  • 27
  • 1
  • 7
0

At the beginning, I get this is a string, not an Int type(1+2 = 12)

The point : Convert string type to int

So the python syntax can solve this problem.(int)

def on_pushButton_17_clicked(self):
    """
    Slot documentation goes here.
    """
    A=self.lineEdit_22.text()
    B=self.lineEdit_23.text()
    A = int(A)
    B = int(B)
    print(A + B)
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Zoe.peace
  • 1
  • 1
  • Whilst this code snippet is welcome, and may provide some help, it would be [greatly improved if it included an explanation](//meta.stackexchange.com/q/114762) of *how* and *why* this solves the problem. Remember that you are answering the question for readers in the future, not just the person asking now! Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. – Toby Speight Feb 24 '17 at 12:45