Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSql: Wrong column displayed when using OnFieldChange!

QSql: Wrong column displayed when using OnFieldChange!

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 590 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jan-Willem
    wrote on last edited by
    #1

    I have a QSqlDatabase with two tables, a main table with about 1839 records and a category table with three record. The second table has only two columns, id and category.

    @model = new QSqlRelationalTableModel(this, db);
    model->setTable("Main");
    model->setEditStrategy(QSqlTableModel::OnFieldChange);
    model->setRelation(1, QSqlRelation("categories", "id", "category"));
    model->select();

    view = new QTableView;
    view->setModel(model);
    view->setItemDelegate(new QSqlRelationalDelegate);@

    When I start the program, everything is just fine. But whenever I change the category, instead of the new string the id is displayed until I call model->select() manualy.
    When I use OnManualSubmit, I have to call model->submitAll() before proceeding.

    How can I make sure the value of category is displayed when using OnFieldChange?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved