PDA

View Full Version : Validating data and aborting process if invalid



nafriadi
12th September 2007, 03:09
I try to make a database application using QTableView, and i need to validate serveral field.
If edited field value does not fit the qualification then the focus may not leave the item delegate.

How can i do to make it ?
(Such in kylix3, i can just call abort, then the process stop and the focus won't go anywhere.)

marcel
12th September 2007, 06:33
You can implement an event filter for the cell's editor and catch and ignore all key events that cause the editor to loose focus and close.
You should consider all cases in which the editor gets closed or looses focus.

Regards

jpn
12th September 2007, 07:36
I do personally hate when applications attempt to force focus to a certain control. Why not just disable the way of proceeding until all cells contain acceptable data? You could for example turn the background of invalid cells to red or something. This gives way more nice user experience and is even less error prone. ;)