PDA

View Full Version : QTableWidgetItem and formatting / input masks



Walter
26th July 2007, 13:04
I have a QTableWidget and for the contained QTableWidgetItem I need...

to set input masks
to format the displayed numbers correctly (e.g. 17.40 or 17,40)


But there is no setInputMask() available for a QTableWidgetItem?
How to format the numbers both during input and during displaying?

Thanks a lot!

Walter
27th July 2007, 11:19
Nobody? So is it not possible and I have to derive my own classes? :(

jacek
27th July 2007, 11:45
You might try to subclass QItemDelegate and reimplement QItemDelegate::createEditor() to make it set an input mask on the line edit. This should be enough, since QTableWidgetItems keep data as strings, so they won't reformat them after editing.

Walter
27th July 2007, 13:39
Thanks.
I am a bit disapointed that I have to code such a simple feature myself. I am just starting to learn Qt and sometimes it seems a bit... eh... low-ended