'pyQt5 - error converting value taken from QTableView
I would need to populate fields of a form based on the values taken from a selected row in a QTableView displayed on another form. The code works fine for text fields but I'm having problem when I have to set the value of a double spinbox: below is the statement which throw an exception. The field dSB_costi has been defined on the form with a double spinbox widget. The issue is the field 'self.model.data(self.model.index(row, 4)' taken from the selected row of the QTableView present in the first form (form1) is passed as string. Additionally the fields taken from the QTableView contains 42,00 as I need use comma as decimal separator. I tried to use float() to convert the value before the setValue statement but I get the error 'ValueError: could not convert string to float: '42,00' Thanks for any guidance you might provide
self.w.dSB_costi.setValue(self.model.data(self.model.index(row, 4)))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
