When I encountered this problem today, the search solution was
table->setFocusPolicy(Qt::NoFocus);
or
table->viewport()->setFocusPolicy(Qt::NoFocus);.
But these methods have some drawbacks, such as the
inability to use the keyboard to control this QTableWidget.
solve
Using QSS can solve this problem perfectly.
Just add
QTableView
{ outline:0px; }
to solve the problem of dotted frame when QTableWidgetItem is selected.
The selected dotted line of the same QTreeWidget is analogous to
QTreeView
{ outline:0px; }