Results 1 to 3 of 3

Thread: QSqlTableModel cannot change values

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

    Default QSqlTableModel cannot change values

    Hi everybody,

    I am not able to change values on my database. But i am able to see the values and change on my tableView..

    Have i forgoten something?

    Qt Code:
    1. model->setTable("words_tbl");
    2. model->setEditStrategy(QSqlTableModel::OnFieldChange);
    3. model->select();
    4. model->removeColumn(0); // don't show the ID
    5. model->setHeaderData(0, Qt::Horizontal, tr("Deutsch"));
    6. model->setHeaderData(1, Qt::Horizontal, tr("Portuguiesisch"));
    7.  
    8. ui.tableView->setModel(model);
    9. ui.tableView->show();
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

  2. #2
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: QSqlTableModel cannot change values

    instead of:

    Qt Code:
    1. model->removeColumn(0); // don't show the ID
    2. model->setHeaderData(0, Qt::Horizontal, tr("Deutsch"));
    3. model->setHeaderData(1, Qt::Horizontal, tr("Portuguiesisch"));
    To copy to clipboard, switch view to plain text mode 

    try this:

    Qt Code:
    1. ui.tableView->setColumnHidden(0, true);
    2. model->setHeaderData(1, Qt::Horizontal, tr("Deutsch"));
    3. model->setHeaderData(2, Qt::Horizontal, tr("Portuguiesisch"));
    To copy to clipboard, switch view to plain text mode 

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

    raphaelf (23rd May 2007)

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

    Default Re: QSqlTableModel cannot change values

    It works thank you
    Think DigitalGasoline

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.