我正在使用python和PyQt5构建软件。单击“设置”时,将弹出“设置”窗口(直到可以正常工作为止)。然后,我希望能保存在一个全局变量(通过QLineEdit的)用户输入值,但分配没有成功。分配后的打印,打印方法给了我2个不同的输出。 (期望它们是相同的)
def openSettingWindow(self):
global grav_used
global airden_used
self.window_setting = QDialog()
self.ui_setting = Ui_SettingWindow()
self.ui_setting.setupUi(self.window_setting)
self.window_setting.show()
self.ui_setting.lineEdit_g.setText(grav_used) #Set default gravity acceleration g value to 9.81m/s^2
self.ui_setting.lineEdit_airDen.setText(airden_used) #Set default air density value to 1.226kg/m^3
grav_used=self.ui_setting.lineEdit_g.text()
airden_used=self.ui_setting.lineEdit_airDen.text()
self.ui_setting.pushButton_settingOK.clicked.connect(lambda: print (self.ui_setting.lineEdit_airDen.text(),airden_used))