Results 1 to 7 of 7

Thread: QTableView and QSQLTableModel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    42
    Thanked 1 Time in 1 Post

    Default QTableView and QSQLTableModel

    Hello everybody

    QT:4.1.1

    I am able with this code to insert a Row in my table:
    Qt Code:
    1. QString table = ui.tabelle_le->text();
    2. model->setTable(table);
    3. model->setEditStrategy(QSqlTableModel::OnFieldChange);
    4. model->select();
    5.  
    6. QSqlRecord rec = model->record();
    7. ui.tableView->setModel(model);
    8. ui.tableView->show();
    9.  
    10.  
    11. rec.setValue("status", "test");
    12. model->insertRecord(-1, rec);
    To copy to clipboard, switch view to plain text mode 

    My problem is, that i have some tables, so i am searching a solution how to implement my function so that i have not to write every columns like:
    table1
    Qt Code:
    1. rec.setValue("status", "test");
    2. rec.setValue("date", "test");
    3. rec.setValue("price", "test");
    4. .
    5. .
    6. .
    To copy to clipboard, switch view to plain text mode 
    table2
    Qt Code:
    1. rec.setValue("address", "test");
    2. rec.setValue("tel", "test");
    3. rec.setValue("mobil", "test");
    4. .
    5. .
    6. .
    To copy to clipboard, switch view to plain text mode 
    I would like to insert a empty row: modal->insertRecord(-1, rec); fill cells and save it
    Can somebody see the problem? Have somebody a idea how to implement this dynamic?
    Last edited by raphaelf; 4th March 2006 at 14:08.
    Think DigitalGasoline

Similar Threads

  1. Replies: 2
    Last Post: 6th January 2009, 20:55
  2. QSqlTableModel and QTableView selection problems
    By innerhippy in forum Qt Programming
    Replies: 5
    Last Post: 19th December 2008, 05:48
  3. QTableView, QSqlTableModel - data disappears
    By msh in forum Qt Programming
    Replies: 1
    Last Post: 15th November 2008, 11:50
  4. QTableView and QSqlTableModel problem
    By Misenko in forum Qt Programming
    Replies: 5
    Last Post: 19th August 2008, 21:58
  5. QSqlTableModel and QTableView and sorting
    By JeanC in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2008, 13:22

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.