Lykurg
25th August 2010, 21:07
Hey,
assuming you have a delegate for a table view containing two columns and selection mode is set to "select rows". Now if you select a cell (in column 0) you get these informations for the cells in the row:
Column 0: QStyle::State_Selected, QStyle::State_HasFocus
Column 1: QStyle::State_Selected
Ok, based on that information I choose the background color; blue when selected and focus, gray when only selected without focus. This has the effect, that if the table has the focus my current line is blue in the the front and gray at the end, but I want it blue from the beginning to the end.
So how can I - in the delegates paint method for QModelIndex(row,1) - determine, if QModelIndex(row,0) has the focus?
The only way I can think of is
qobject_cast<QTableView*>(parent())->hasFocus()assuming the view is parent of the view. But that is nasty.
So does anyone knows a better way?
Thanks.
assuming you have a delegate for a table view containing two columns and selection mode is set to "select rows". Now if you select a cell (in column 0) you get these informations for the cells in the row:
Column 0: QStyle::State_Selected, QStyle::State_HasFocus
Column 1: QStyle::State_Selected
Ok, based on that information I choose the background color; blue when selected and focus, gray when only selected without focus. This has the effect, that if the table has the focus my current line is blue in the the front and gray at the end, but I want it blue from the beginning to the end.
So how can I - in the delegates paint method for QModelIndex(row,1) - determine, if QModelIndex(row,0) has the focus?
The only way I can think of is
qobject_cast<QTableView*>(parent())->hasFocus()assuming the view is parent of the view. But that is nasty.
So does anyone knows a better way?
Thanks.