I am trying to change the text inside the Line Edit after some operations. I am getting correct results in terminal using print but not updated in the Line Edit.

i am expecting to replace the old value with the new value. example, old value is 2 and the new value is 4, it is showing both old and new values. Expected new value: 4 Shown value: 24 together (old and new values). I tried to use the clear function for the Line Edit but still shows both values.


class Second(QtWidgets.QMainWindow):
def __init__(self,parent=None):

super(Second, self).__init__(parent)
self.ui = Ui_MainWindow2()
self.ui.setupUi(self)
self.setWindowTitle("User Logged In")
self.ui.pushButton_14.clicked.connect(self.plus)

def plus(self):
global newx
newx = newx + int(self.ui.lineEdit.text())
self.ui.lineEdit.setText(str(newx))