How to disable selection highlighting in a QTableWidget

Tobias Leupold picture Tobias Leupold · Jul 26, 2014 · Viewed 15.3k times · Source

I have a QTableWidget with a disabled setSelectionMode (QTableWidget::NoSelection) and the QTableWidgetItems I fill in don't have the Qt::ItemIsEditable flag.

Nevertheless, a cell that has been clicked gets some kind of cursor (the black line at the bottom in my case):

Highlighted cell

How can I disable this "cursor"?

Answer

Senthil Kumar picture Senthil Kumar · Jan 24, 2017
#include <QTableWidget>



tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
tableWidget->setFocusPolicy(Qt::NoFocus);
tableWidget->setSelectionMode(QAbstractItemView::NoSelection);

These statements will disable the selection of table in cells..