QTableView displays column heading incorrectly when displaying results of a SQL query?
-
Here is some reconstructed code (ie not independantly tested):
@QSqlQueryModel *model = new QSqlQueryModel;
model->setQuery("SELECT type, COUNT(titles.title) FROM titles GROUP BY type");
QTableView view = new QTableView;
view->setModel(tableModel);
mainLayout->addWidget(view);
show();@The code queries a table "titles" which contains a list of book titles and their types (business, cooking, sport, etc) plus other stuff.
The column headings display correctly apart from that for
@COUNT(titles.title)@
which displays as
@title)@However if instead I have @COUNT(title)@ the column heading displays correctly, ie as
@COUNT(title)@Possibly related to this problem: "titles.type" displays as "type".
This all becomes a big issue when attempting to correctly display the headings for the results of a join.
Thinking about it, this may be an HTML related problem, ie the view thinks it should be parsing HTML in the heading.
-
I agree with ZapB (Sean). Did you check what the column title for that query is if you run it through your DB directly? What DB are you using?
AFAIK, most Qt SQL drivers won't just make up names for columns themselves. Instead, they get them from the database engine they interact with. There may be a bug in that interaction, of course, but you should try to determine the source of that problem.
-
I've raised fault report "QTBUG-18095":http://bugreports.qt.nokia.com/browse/QTBUG-18095
Edit: fixed link; Andre