nagabathula
10th August 2011, 19:02
Hello every one i have a QTableView in which i am displaying data from the sql database.. I am stuck at a small problem i wanted to display Header names for all the channel's which i have appended in a QStringList. I tried many things but i get the database table column name's as the header's.
QSqlQueryModel *model = new QSqlQueryModel(tableView);
model->setQuery("SELECT "+ colNames +" from thdata where rowid = (select max(rowid) from thdata)");
tableView->setModel(model);
tableView->showMaximized();
tableView->setAlternatingRowColors(true);
//tableView->setHorizontalHeader(thermoNames);
//tableView->setHorizontalHeaderLabels(QString(thermoNames));
tableView->resizeRowsToContents();
tableView->resizeColumnsToContents();
timeinterval.clear();
tableView->verticalHeader()->setVisible(false);
colNames.clear();
this is what i am doing to display all the channels data from the database table, but the header is the column names in the Table i wanted to display the header names which i have defines and stored in a QString thermoNames; , Pls help me out.
Thank you
QSqlQueryModel *model = new QSqlQueryModel(tableView);
model->setQuery("SELECT "+ colNames +" from thdata where rowid = (select max(rowid) from thdata)");
tableView->setModel(model);
tableView->showMaximized();
tableView->setAlternatingRowColors(true);
//tableView->setHorizontalHeader(thermoNames);
//tableView->setHorizontalHeaderLabels(QString(thermoNames));
tableView->resizeRowsToContents();
tableView->resizeColumnsToContents();
timeinterval.clear();
tableView->verticalHeader()->setVisible(false);
colNames.clear();
this is what i am doing to display all the channels data from the database table, but the header is the column names in the Table i wanted to display the header names which i have defines and stored in a QString thermoNames; , Pls help me out.
Thank you