[Qt-interest] QAbstractItemModel::setHeaderData() and headerData()
j
j at dynamica.org
Fri Jan 29 15:17:30 CET 2010
hi there,
Im a bit confused as to how to set the header data
of a model. I have a class A that inherits from both
QAbstractTableModel and QTableView that has an
initialisation function in which I call
...
setHeaderData( 0, Qt::Horizontal, QObject::tr("property") );
...
I did not implement the headerData function.
unfortunately, the header shows '0' in section 0,
where I expect it to display 'property'.
when I do implement headerData like this:
QVariant A::headerData( int section,
Qt::Orientation orientation,
int role ) const
{
if( role == Qt::DisplayRole )
{
switch( section )
{
case 0: return( QString( "property" ) );
case 1: return( QString( "type" ) );
case 2: return( QString( "value" ) );
}
}
return QAbstractItemModel::headerData( section, orientation, role );
}
and omit the setHeaderData call in the initialisation routine,
all is fine, and the header displays what I expect.
what's going on ?
Jonathan
More information about the Qt-interest-old
mailing list