List data from two tables in tableView

1

What do I do to list data from two tables in tableView?

Database (Example) Sqlite:

tb_venda
  tb_produto
  tb_valor
  tb_cliente_id (Id do cliente "tb_cliente")

tb_cliente
  tb_cliente_id (id primary key)
  tb_nome  
  tb_estado

With QSqlRelationalTableModel I can only bring the client's name. I also need the state.

relacao = new QSqlRelationalTableModel(this); 
relacao->setTable("tb_venda");
relacao->setRelation(2, QSqlRelation("tb_cliente", "tb_cliente_id", "tb_nome"));
relacao->select();
ui->tableView->setModel(relacao);
    
asked by anonymous 04.07.2014 / 16:08

1 answer

0

Resolved: QSqlRelationTableModel has only one column. To fix the problem, I had to use QSqlQueryModel with LEFT JOIN .

    
08.07.2014 / 16:40