QTableView: changing precision for double values
I haven't been able to find a good way to get to these spin boxes. The default delegate for QTableView
is QStyledItemDelegate . When you create an item in, Qt::EditRole
it uses items created by the standard QItemEditorFactory class , which you can access using QItemEditorFactory::defaultFactory()
. Then you could register your own editor, but I don't see a good way to edit the ones that already exist.
Instead, you should most likely implement your own delegate with some precision. There is an example to make a delegate using QSpinBox
which you replace with QDoubleSpinBox
. Then in createEditor
you then use setDecimals
to set the spin box to the precision you want. Then you apply this delegate to your table using setItemDelegate
.
source to share