PDA

View Full Version : QTableView, slect a full row



titoo
13th February 2007, 11:25
i want to select a whole row in a QTableView
i have tried to parameterize the table view with

setSelectionBehavior( QAbstractItemView::SelectRows );

but still only the current QStandardItem is selected and not the full row, even if i use

setCurrentIndex( oItem->index() );
selectRow( oItem->row() );

any clue ?

titoo
13th February 2007, 17:09
the problem is that i use a QItemDelegate to draw the first column and so i loose the highlight property applied to the second column. how to keep the background same on both columns ?

wysota
13th February 2007, 20:22
QItemDelegate is always used. You shouldn't lose any functionality if you apply a custom delegate to any column or row provided that your custom delegate knows how to draw items which are selected. Something else must be wrong. What data do you store in your items? What flags() do the items return? Is ItemIsSelectable among them?

titoo
14th February 2007, 09:58
i have tried many settings of the qtreetable but so far the problem i see is that if i use the method selectRow() and then clearSelection() with a qtableview setted for accepting a single selected item plus rows selection i cant unselect rows selected with selectRow() even by using clearSelection(). i have seen we can create our own selection behavior, i think i will try this way. still there are some bugs in qt atm about this, standard behaviors QAbstractItemView::SingleSelection and QAbstractItemView::SelectRows dont stack properly and if you use selectRow() you cant unselect the row later on, even with clearSelection()

titoo
14th February 2007, 11:38
i need to force by using resize to get only the full row selected (and not the other ones) even if this behavior was asked with QAbstractItemView::SingleSelection and QAbstractItemView::SelectRows.
i have tried repaint and other refresh methods but only resize functions
maybe a bug from my code, still sounds like a qt bug to me