Pyside:QLineEdit接受多个输入

2024-04-24 06:45:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Qt设计器中开发了一个GUI,用户可以在QLineEdit中输入两个值,当用户点击enter时,它执行一些数学计算。在

问题是一旦输入值并在输出后按下enter键,我就无法在QLineEdit中输入输入,但每次都必须重新启动GUI。这是我的代码:

    def entervalues(self):
        if self.RotationEdit.text() != "" and self.TiltEdit.text() != "":
            self.RotationEdit = str(self.RotationEdit.text())
            self.TiltEdit = str(self.TiltEdit.text())
            self.pass_arguments.emit("self.RotationEdit","self.TiltEdit")
        else:
            QMessageBox.information(self, "Error","No Values Entered")

如果我给出了输入错误的属性值。在

^{pr2}$

enter image description here


Tags: 代码text用户selfifdefguiqt
1条回答
网友
1楼 · 发布于 2024-04-24 06:45:05

问题是在代码中更改了对象self.RotationEdit

self.RotationEdit = str(self.RotationEdit.text())

当您最初声明这是一个QLineEdit,但随后指定了一个字符串。当您重用它时,它仍然是字符串,因此text()函数没有定义。我建议创建一个新变量,该变量包含将在另一个函数中使用的值。在

^{pr2}$

相关问题 更多 >