How do you get the name of a column from a QSqlQueryModel if all I have is the index?
Thanks!
How do you get the name of a column from a QSqlQueryModel if all I have is the index?
Thanks!
You can use QSqlQueryModel::record() or headerData() for this.
Thanks, I got caught up looking in the wrong place.
If anyone else ever asks, I used:
int row = 0;
int column = 0;
QString columnName = model->record(row).fieldName(column);
It's a bit more efficent to use the record() method without parameters, since you don't need a record populated with data:
The version with headerData() looks like this:Qt Code:
To copy to clipboard, switch view to plain text mode
(although in some cases it might not return the original name of the column).Qt Code:
To copy to clipboard, switch view to plain text mode
Bookmarks