QTableWidget display certain decimals like excel

Viewed 2786

My question is about the way the QTableWidget displays the cell values.

I'd like for the cell to show only three decimals when it's not being edited and show the full value when you double click for editing.


I am doing calculations in background and then setting the cell value afterwards.

V_D = 3/0.7
self.TableWidget.setItem(0, 0, QTableWidgetItem(str(V_D)))

Similar to the way excel formats the cell to show certain number of digits.

Full Value:

enter image description here

Display Value:

enter image description here

How would I go about doing this?

1 Answers
Related