View Full Version : QTableView replace row number with sign
Hostel
22nd May 2013, 20:30
I want to replace row number in QTableView with '>' char. How can I do this?
KaptainKarl
22nd May 2013, 21:12
You need to set the values for the horizontal headers in an implementation of headerData() or setHeaderData() in your model.
See QAbstractItemModel.
Karl
Hostel
22nd May 2013, 21:34
setHeaderData has roles and I don't see role which will make ">" in vertical header. Can you paste a code? Maybe I'm doing something wrong.
KaptainKarl
22nd May 2013, 21:43
See if this qtcentre post helps: http://www.qtcentre.org/threads/43820-show-User-Defined-Header-Labels-in-QTableView
Karl
Hostel
22nd May 2013, 22:13
It not helps. I need this:
9054
Added after 11 minutes:
Ok I have solution:
// my model
QVariant TestModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if( orientation == Qt::Vertical && role == Qt::DisplayRole )
{
return QVariant( ">" );
}
else
{
return QSqlRelationalTableModel::headerData( section, orientation, role );
}
}
KaptainKarl
22nd May 2013, 22:20
After you create the model and call select(), add the vertical headers like this:
for(int i=0; i<model->rowCount(); i++)
{
model->setHeaderData( i, Qt::Vertical,">");
}
Karl
ChrisW67
22nd May 2013, 22:39
You could use also QIdentityProxyModel to replace the header text.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.