PDA

View Full Version : QTableWidget + setSelectionMode()



BIllNo123
7th December 2010, 10:42
Hello all,

i have a QTableWidget with 3 rows and 3 columns. When user clicks on a widget (they are widgets not items...) then the whole row in which the widget belongs is selected. For example, if i click on widget on cell (0,0) then the cells (0,0), (0,1) and (0,2) are selected. What i do is to find the row the widget belongs to and then do the following:
table->setSelectionMode(QAbstractItemView::ContiguousSele ction); //in order to select the cells in the same row
table->selectRow( RowWidgetBelongsTo );
table->setSelectionMode(QAbstractItemView::SingleSelectio n); //in order to prevent user from selecting multiple cells

The problem is that if the user presses the "shift" button when he clicks on a cell, then he is able to select multiple cells...
Any ideas?

franz
7th December 2010, 12:06
You will probably have to redefine the key press event handling for this widget.

BIllNo123
7th December 2010, 12:20
solution given:
http://www.qtforum.org/article/35160/qtablewidget-setselectionmode.html

(sorry if not allowed to do this)