Ok, I found this other thread which enlightened me to enhancing the flag method, too. Since my model extends the QSqlQueryModel, here is what is being returned for the check box column:
Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled
I also tweaked what the data method was returning:
if(index.column() == _isInSlideShowIdx)
{
if (role == Qt::CheckStateRole)
return QSqlQueryModel::data(index, Qt
::DisplayRole).
toBool() ? Qt
::Checked : Qt
::Unchecked;
else if( role == Qt::DisplayRole)
}
if(index.column() == _isInSlideShowIdx)
{
if (role == Qt::CheckStateRole)
return QSqlQueryModel::data(index, Qt::DisplayRole).toBool() ? Qt::Checked : Qt::Unchecked;
else if( role == Qt::DisplayRole)
return QVariant();
}
To copy to clipboard, switch view to plain text mode
But I still have issues:
- The check box is always on the left
- When I click on the check box cell, it makes the space to the right of the check box an editbox control
- When I added a delegate to create a check box editor, I had to still double click on the space to the right to make the editor active, and the editor is offset to the left by a pixel or two.
Any thoughts on how to fix this?
Bookmarks