Results 1 to 3 of 3

Thread: Qt Sql :how can update data in different tables when i use qTableModel

  1. #1
    Join Date
    Oct 2012
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt Sql :how can update data in different tables when i use qTableModel

    Hi ,everyone! i am using qt sql to do a small software,but i encountered some difficulty;
    i don't know how to update data in other table when i update one ;
    eg: table A( name text , address text,primary key(name) );
    table B(id integer,name references A(name),tel integer);

    when i update field name in table A ,how can i update field name in table B, the point is that i use the QSqlTableModel to handle the data updating,
    i find a signal called 'beforeUpdate' in QSqlTableModel,but it seems that the signal is emitted before update data in dataBase not before update data in model, so i come to look for help,my english is not good,thx!

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

    Default Re: Qt Sql :how can update data in different tables when i use qTableModel

    What do you mean by "update the field name"?

    If two views are sharing the same QSqlTableModel then changes to the data in the table in one view will be visible in the other.

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

    hqh (4th January 2014)

  4. #3
    Join Date
    Oct 2012
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Sql :how can update data in different tables when i use qTableModel

    sorry,i didn't make it clear. i mean using "update tableName set field=?"statement when i say update field name. and the 'table' is a sql table not a tableView , but the point is that i have only use a tableView and i want to update data cascade, and that means when i change one field which is the foreign key of another table,it is expected that the foreign key in another table also makes change. in the SQL manage ,there is something called "cascade",it's similar to this! anyway ,thanks!

Similar Threads

  1. Replies: 13
    Last Post: 6th December 2010, 04:41
  2. Replies: 4
    Last Post: 13th July 2010, 05:17
  3. Replies: 1
    Last Post: 16th May 2010, 19:25
  4. Way to load all of data from 2 tables into one QTableView?
    By Kevin Hoang in forum Qt Programming
    Replies: 8
    Last Post: 3rd April 2010, 09:42

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.