Row selection
-
wrote on 26 Jun 2015, 07:11 last edited by
Hi all,
I'd like to allow row selection by clicking vertical header and prevent cell and column selection. How can I do that ?
Thanks
-
Hi and welcome to devnet,
Do you mean this ?
-
wrote on 29 Jun 2015, 06:24 last edited by
Hi, thanks for the reply. Yes, I set that flag to true but I can select a row by clicking indivual cell or horizontal header. I've overriden flags function in my model if I remove isSelectable flag i can't select anything.
Qt::ItemFlags TableModel::flags(const QModelIndex &index) const { if(!index.isValid()) { return Qt::ItemIsEnabled; } if(index.column() == 1) { if(modelList.at(index.row()).isArray) { return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEditable; } return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; } return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable; }
1/3