PDA

View Full Version : Qtablewidget make rows not selectable



gab74
2nd December 2011, 14:16
Good morning,
i've a QTablewidget, 2 cols, 3 rows.

i use :

mytable->setSelectionBehavior(QAbstractItemView::SelectRows ); //to select a row
mytable->setSelectionMode(QAbstractItemView::SingleSelectio n); //to have single selection.

All well,
now i want to disable the onclick selection, when a row is empty, (so the row background color remains unchanged, and no empty row is porcessed)

How can i disable the oncick selection for a certain row ?

Thanks Gabriele

Santosh Reddy
5th December 2011, 04:44
//On each item of the empty row you need to call
QTableWidgetItem::setFlags(Qt::NoItemFlags);

gab74
5th December 2011, 12:39
Thank you for your answer...it brings me in the right direction...
Unfortunately i use old QT 4.2.3 and this flag does not exist.
i use setFlags(Qt::ItemIsEditable)...this works and the line is not selectable..
but problems remains...the row is not selectable but the values is passed.
I've a button..and when i clicks..the value is passed even if the row seems to be unselectable...