Hello everybody
I have the task to insert the QCheckBox item into the vertical header.
I looked through the demos (itemview) where picture (the star) is inserted into the vertical header by reimplementing 
	
		
			
			
				method QVariant QAbstractItemModel::headerData ( int section, Qt::Orientation orientation, int role = Qt:: DisplayRole ) const  [virtual]
			
		
 
	 
 
	
	- QVariant-  Model ::headerData(int-  section, Qt ::Orientation-  orientation,  int-  role ) const
 
- { 
-     if (role == Qt::DisplayRole) 
-     if (role == Qt::DecorationRole) 
-         return qVariantFromValue(services); 
- } 
        QVariant Model::headerData(int section, Qt::Orientation orientation, int role) const
{
    static QIcon services(QPixmap(":/images/services.png"));
    if (role == Qt::DisplayRole)
        return QString::number(section);
    if (role == Qt::DecorationRole)
        return qVariantFromValue(services);
    return QStandardItemModel::headerData(section, orientation, role);
}
To copy to clipboard, switch view to plain text mode 
  Then I try to reload this method for my own model (CustomModel)
	
	- QVariant-  CustomModel ::headerData(int-  section, Qt ::Orientation-  orientation,  int-  role ) const
 
- { 
- 	if (role == Qt::DisplayRole) 
- 	if (role == Qt::UserRole) 
- 		return qVariantFromValue(object); 
- } 
        QVariant CustomModel::headerData(int section, Qt::Orientation orientation, int role) const
{
	if (role == Qt::DisplayRole)
		return QString::number(section);
	QObject *object = new QCheckBox;
	if (role == Qt::UserRole)
		return qVariantFromValue(object);
	return QStandardItemModel::headerData(section, orientation, role);
}
To copy to clipboard, switch view to plain text mode 
  
but there is no effect.
Help me please.
				
			
Bookmarks