Results 1 to 10 of 10

Thread: Form update problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    67
    Thanks
    22
    Thanked 5 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Form update problem

    I am trying to update my form with the following code by the form won't save the edits.

    Qt Code:
    1. tableModel->select();
    2. QModelIndex index = ui.tableView->currentIndex();
    3. QString sqlQuery = QString("UPDATE %1 SET firstname=:firstname, lastname=:lastname, country=:country, city=:city WHERE id=:id)").arg(tableName);
    4. query.prepare(sqlQuery);
    5. QSqlRecord recordz = tableModel->record(index.row());
    6.  
    7. query.bindValue(":firstname", ui.fEdit->text());
    8. query.bindValue(":lastname", ui.lnEdit->text());
    9. query.bindValue(":country", ui.cEdit->text());
    10. query.bindValue(":city", ui.cityEdit->text());
    11. query.bindValue(":id", recordz.value("id").toInt());
    12. query.exec();
    13. tableModel->submitAll();
    To copy to clipboard, switch view to plain text mode 
    Last edited by thefatladysingsopera; 12th September 2011 at 13:36.

Similar Threads

  1. update form
    By hamidarr in forum Qt Programming
    Replies: 10
    Last Post: 25th June 2011, 21:22
  2. QTableWidget update problem
    By mammenj in forum Qt Programming
    Replies: 2
    Last Post: 13th August 2010, 06:46
  3. Problem with .ui form
    By Fenix Voltres in forum Qt Tools
    Replies: 0
    Last Post: 14th September 2009, 17:37
  4. Form problem
    By dusza in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2009, 22:41
  5. View update problem
    By prakash in forum Qt Programming
    Replies: 6
    Last Post: 17th March 2006, 10:13

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