PDA

View Full Version : Change tableView vertical header



tinysoft
16th September 2011, 15:16
Hi every one..

How can i change QTreeView vertical header?

the QTreeView is presenting QSqlQueryModel .

l tried to do it this way but it did not work :



QSqlQuery qury;

QSqlQueryModel tableModel;

qury.exec("select * from table;");
tableModel.setQuery(qury);

ui->tableWidget->setModel(&tableModel);

for (int i=0; i<=14;i++)
tableModel.setHeaderData(i, Qt::Vertical, stringList[i]);

this code is working fine when i use it for the Horizontal header :


for (int i=0; i<=14;i++)
tableModel.setHeaderData(i, Qt::Horizontal , stringList[i]);

any ideas ?

thanks in advanced ..

wysota
17th September 2011, 08:35
QSqlQueryModel doesn't allow to store information in the vertical header. If I'm correct then from the built-in models only QStandardItemModel allows that. You need to subclass your model, reimplement setHeaderData() and store the data you want in some container. Then reimplement headerData() and return data from your container when requested.