How to choose which columns to display and in which order when using QSqlRelationalTableModel?
-
I have a QSqlRelationalTableModel but there is no way to select which columns to display and in what order...
If I replace it with a query string then I lose the setRelation() functionality which is very valuable to me
How can I specify which columns I want to display and still have the setRelation() functionality?Thanks!
-
but I don't'see a method moveColumn()
But (and I see @SGaist has just posted) you don't want to move columns around in the model to change the order they are displayed. You do this in the view, the
QHeaderView
which is theQTableView::horizontalHeader()
, by moving its sections. -
@jdent
I don't understand. AQSqlRelationalTableModel
is aQSqlTableModel
just with additional "look up" of column(s) in other table(s) for display and editing purposes.It is not about mapping to another table and then being able to pick arbitrary rows or columns there, your own
JOIN
s etc., which I think you might be thinking about.Per your other question, again I think you're hoping for too much from the base
QSql
classes. I came from MS .NET data classes, they offered a lot more if you're looking for DataSet-level stuff, -
Hi,
That's the kind of things you do at the QTableView and/or QHeaderView level.
-
-
but I don't'see a method moveColumn()
But (and I see @SGaist has just posted) you don't want to move columns around in the model to change the order they are displayed. You do this in the view, the
QHeaderView
which is theQTableView::horizontalHeader()
, by moving its sections. -