How to display content of multiple QSqlTableModels in one QTableView?

后端 未结 1 1266
遇见更好的自我
遇见更好的自我 2021-01-07 11:07

I have a MySql table, let\'s call it x:

CREATE TABLE x (
    Id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
    A int unsigned NOT NU         


        
相关标签:
1条回答
  • 2021-01-07 11:33

    You can use QSqlQueryModel with sql join query:

    QSqlQueryModel *model = new QSqlQueryModel;
    model->setQuery("SELECT x.Id, y.First, y.Last, x.B FROM x "
                    "LEFT JOIN y ON x.A = y.Id");
    
    QTableView *view = new QTableView;
    view->setModel(model);
    view->show();
    
    0 讨论(0)
提交回复
热议问题