Results 1 to 2 of 2

Thread: How to check if insert was success in a QTableModel/QTableView approach

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2013
    Posts
    43
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    27
    Thanked 6 Times in 5 Posts

    Default How to check if insert was success in a QTableModel/QTableView approach

    Hello,

    This code inserts records in a MySQL table:
    Qt Code:
    1. int row = 0;
    2. model->insertRows(row,1);
    3. QModelIndex index = model->index(row, model->fieldIndex("idPK"));
    4. view->setCurrentIndex(index);
    5. view->edit(index);
    To copy to clipboard, switch view to plain text mode 

    If i repeat the the value in the Primary Key or leave NULL a mandatory field, the data will remain visible in the view but, as soon as i refresh the model, i realise it was not there.

    How showld i control this?

  2. The following 2 users say thank you to aguleo for this useful post:


Similar Threads

  1. Replies: 16
    Last Post: 28th April 2020, 14:40
  2. Qtableview insert row and column
    By maarvi in forum Newbie
    Replies: 1
    Last Post: 1st July 2011, 09:26
  3. Best (and easiest) approach, QCombobox and QTableView...
    By scott_hollen in forum Qt Programming
    Replies: 2
    Last Post: 29th March 2011, 14:07
  4. QTableView QTablemodel & insertRow
    By pfusterschmied in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2007, 12:43
  5. Insert QCheckBox into QTableView
    By wind in forum Qt Programming
    Replies: 3
    Last Post: 8th October 2006, 16:15

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.