Results 1 to 4 of 4

Thread: QTableView QItemDelegate validation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    29
    Thanks
    10

    Default QTableView QItemDelegate validation

    Hello!

    I am trying to prevent the user to enter to enter incorrect values in a QTableView. What I would like to do is check the contents of the cell at the end of the edition and prevent the user to leave to editor if the value is wrong.

    I have been playing with a QItemDelegate and with the signal closeEditor. What would be the proper way to do it?

    The ideal that I would like to achieve is, in case of an error, to prevent the user to leave the editor of a cell and even to prevent him from saving the data.

    Thank you!

  2. #2
    Join Date
    Apr 2009
    Posts
    36
    Thanks
    1
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView QItemDelegate validation

    If your editor is using a QLineEdit, QComboBox, or QSpinBox, then each of these widgets has a setValidator function for a QValidator subclass.

    Look here for more info: http://qt.nokia.com/doc/4.6/qvalidator.html

  3. The following user says thank you to bmhautz for this useful post:

    pippo42 (8th March 2010)

  4. #3
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Default Re: QTableView QItemDelegate validation

    I concur, you dont need to go through all that trouble, just use the validator and it works even as the user is entering the data so you dont have to wait till the end.

  5. The following user says thank you to yodasoda for this useful post:

    pippo42 (8th March 2010)

  6. #4
    Join Date
    Nov 2009
    Posts
    29
    Thanks
    10

    Default Re: QTableView QItemDelegate validation

    Thanks I will try with the validator.

    Sorry for not replying earlier. I was abroad.

Similar Threads

  1. Replies: 2
    Last Post: 6th September 2011, 11:27
  2. XML Validation
    By NoRulez in forum Qt Programming
    Replies: 4
    Last Post: 15th September 2010, 13:07
  3. MessageBox Validation
    By fortyhideout12 in forum Newbie
    Replies: 10
    Last Post: 2nd September 2009, 17:14
  4. Validation
    By Tavit in forum Qt Programming
    Replies: 2
    Last Post: 21st March 2009, 07:03
  5. XML DTC validation problem
    By shailesh in forum Qt Programming
    Replies: 1
    Last Post: 16th March 2006, 13:12

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
  •  
Qt is a trademark of The Qt Company.