Results 1 to 4 of 4

Thread: QTableWidgetItem and formatting / input masks

  1. #1
    Join Date
    Jun 2007
    Location
    Austria (Europe)
    Posts
    31
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTableWidgetItem and formatting / input masks

    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!

  2. #2
    Join Date
    Jun 2007
    Location
    Austria (Europe)
    Posts
    31
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidgetItem and formatting / input masks

    Nobody? So is it not possible and I have to derive my own classes?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidgetItem and formatting / input masks

    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.

  4. The following user says thank you to jacek for this useful post:

    Walter (27th July 2007)

  5. #4
    Join Date
    Jun 2007
    Location
    Austria (Europe)
    Posts
    31
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidgetItem and formatting / input masks

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.