简体   繁体   English

在 QlineEdit PyQT 中设置变量

[英]Setting a variable in a QlineEdit PyQT

I need to put a value of an element ( float) of a list into a QlineEdit of GUI i developed with Qt Designer.我需要将列表的元素(浮点数)的值放入我使用 Qt Designer 开发的 GUI 的 QlineEdit 中。

raw = self.model_lineEdit.text()  
print('raw : ', raw)
ic,E = zip(*[ list(map(float,line.split(", "))) for line in raw.split("\n") ])
E,ic = np.array(E),np.array(ic)
self.Eoff1_lineEdit.setText(E[3]) 

Unfortunately, it does not work.不幸的是,它不起作用。 Can someone help me please ?有人能帮助我吗 ? Thank you in advance and have a good day :) !提前谢谢你,祝你有美好的一天:)!

Probably it is because you are actually trying to write something different from a string.可能是因为您实际上是在尝试编写与字符串不同的东西。

To ensure that your data is passed as string, you have to use为了确保您的数据作为字符串传递,您必须使用

self.Eoff1_lineEdit.setText(str(E[3]))

instead of代替

self.Eoff1_lineEdit.setText(E[3])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM