Results 1 to 2 of 2

Thread: QTableView, Sqlite db adds data although I press ESC key during table edit

  1. #1
    Join Date
    Jan 2013
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTableView, Sqlite db adds data although I press ESC key during table edit

    When I press the ADD button in my program I end up in the tableview edit mode and there I enter some text in the first two fields out of three but then I press ESC key which then puts me back in the tableview list and the new record seems to have been discarded which should be correct behavior. The problem is that the record is actually stored in the DB but I have to refresh the tableview to show it. Is there anyway I can catch this "ESC keypress" in the model setData method? Something like if (row edit is cancelled) then don't save it to DB else return QSqlTableModel::setData(index, value, role)? I´m very new to qt model/view programming but have some minor understanding of the concept.

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

    Default Re: QTableView, Sqlite db adds data although I press ESC key during table edit

    We cannot any of how your program is constructed and what pressing the "ADD" button does.

    You probably want to check QSqlTableModel::editStrategy(), but the default behaviour does not do what you are describing.

Similar Threads

  1. Update changes in QTableView to sqlite data base
    By nagabathula in forum Qt Programming
    Replies: 2
    Last Post: 12th November 2011, 01:18
  2. QTableView, sqlite, wrong data type
    By bzqt in forum Newbie
    Replies: 1
    Last Post: 10th October 2011, 23:56
  3. QTableView with QSqlTableModel - change widget for edit data
    By elektrrrus in forum Qt Programming
    Replies: 3
    Last Post: 24th February 2011, 15:51
  4. Replies: 1
    Last Post: 3rd April 2010, 15:47
  5. Replies: 0
    Last Post: 4th December 2008, 05:48

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.