Important: Please read the Qt Code of Conduct -

QSqlRelationalTableModel and QTableView::setColumnHidden

  • Hello :)

    I am using QSqlRelationalTableView to serve as a mediator between two tables and my QTableView.

    So far, it's working well. The tables are correctly relationed and you see what must be seen :)

    But now I want to hide the index and another column that are of no use for the final user. So I tried:

    ui->tableView_cascosYAccesorios->setColumnHidden(myBudget->models.cases_and_accesories->fieldIndex("id"), true); ui->tableView_cascosYAccesorios->setColumnHidden(myBudget->models.cases_and_accesories->fieldIndex("presupuesto"), true);

    I have also tried writing the column number directly (0 and 1), but that doesn't change anything. The columns still appear.

    I wonder if the order in which the models are assigned to the views and the setColumnHidden might matter or not?

    Thanks for any pointer. If you need code just ask, I just don't know what could be relevant, since, aside from setColumnHidden not working, everything else works as it should...

  • I ended up ditching the relational tables altogether, and using my own custom delegate instead.

Log in to reply