Results 1 to 4 of 4

Thread: Howto validate input in QStandardItem

  1. #1
    Join Date
    Mar 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Howto validate input in QStandardItem

    Hi guys,

    I'm feeling as a newby (am one mayby )
    I'm in code project and got a problem I can't solve in a simple way or can't see the solution.

    Have a Table that I populate with QStandardItem's into a QStandardItemModel and filter through a QSortFilterProxyModel with 3 columns.
    All data can be changed, the first column with any text and the rest should be validated numeric US formatted double ('.' separator) and max 8 digits.

    Have looked and tried but not found any way to validate like the QValidators example gives the validation.

    Any ideas how to set the validation to the two double column items?
    Can I use QDoubleValidator in any way?



    /anders
    Last edited by andsun; 13th May 2015 at 08:30.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Howto validate input in QStandardItem

    Provide your table view with a custom QStyledItemDelegate for the columns concerned and provide either a suitable QDoubleSpinbox, or a QLineEdit with an attached validator in the createEditor() function.

  3. #3
    Join Date
    Mar 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Howto validate input in QStandardItem

    Hi and thks,

    shall give them a try.
    Testing spinbox at the moment, though at doesn't show in the cell when doubleclick

    Shall change to DoubleSpinbox and try...

    /a

  4. #4
    Join Date
    Mar 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Howto validate input in QStandardItem

    Thank's ChrisW67

    It worked with subclassing into DoubleSpinBoxDelegate, as spinbox example for col 1 -2.

    /a

Similar Threads

  1. Validate TextField
    By porterneon in forum Qt Quick
    Replies: 0
    Last Post: 12th November 2014, 14:57
  2. How to validate a form?
    By homerun4711 in forum Newbie
    Replies: 8
    Last Post: 28th February 2011, 18:47
  3. Replies: 1
    Last Post: 30th July 2010, 07:23
  4. Replies: 4
    Last Post: 14th June 2010, 15:01
  5. How to validate XML against DTD?
    By emental86 in forum Qt Programming
    Replies: 2
    Last Post: 29th April 2009, 13:11

Tags for this Thread

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.