Search code examples
pythonqtpyqtqlineedit

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.

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 :) !


Solution

  • 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])