I have 3 tables:
I would like to show the Orders table (order's start and end date, user's last name, service name and service price) on GUI using QTableView and QSqlRelationalTableModel. Here's where I set up the table and the view:
this->ordersTable = new QTableView(this);
this->model = new QSqlRelationalTableModel(this, db->getDB());
this->model->setTable("ORDERS");
this->model->setRelation(3, QSqlRelation("USERS", "id", "lastname"));
this->model->setRelation(4, QSqlRelation("SERVICE", "id", "name"));
this->model->setRelation(4, QSqlRelation("SERVICE", "id", "price"));
this->model->select();
this->ordersTable->setModel(this->model);
this->ordersTable->hideColumn(0);
But when I do the third setRelation call, it seems, it overwrites the second call: I can only see the price on GUI, not both the name AND the price. And I need to put both fields - name and price from Services table to my view.

It seems
setRelationis used to resolve only one foreign key, but you want to add two columns. In this case you can useQSqlQueryModelto apply your own customized query.For the query, you could achieve your goal with a simple inner join query.