2

I want my table to be not selectable, so that only check boxes or radio buttons could be selected, but not the cell itself. Now I have:

enter image description here

How can I fix this?

Solutions for QTableWidget can help too.

  • 1
    Maybe this helps: https://doc.qt.io/qt-5/qabstractitemview.html#SelectionMode-enum – hyde Apr 02 '20 at 09:31
  • Also, if you haven't already, I strongly recommend skimming through that whole doc page, and reading the explanatory text sections. Same for the model. It really helps if you have some idea what all is provided by the API. – hyde Apr 02 '20 at 09:34
  • 1
    You might look at `Qt::ItemIsSelectable` flag. Unset it for all items in your table model. – vahancho Apr 02 '20 at 09:47
  • @hyde your linked helped me. – Narek Hambardzumyan Apr 02 '20 at 13:07

1 Answers1

6
QTableView *test = new QTableView();
test->setSelectionMode(QAbstractItemView::NoSelection);

gives the wanted result.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241