[Qt-interest] changing the way semected items of a QTableView do appear
TP
paratribulations at free.fr
Wed Nov 10 00:24:05 CET 2010
Hello,
The default appearance of selected items in a QTableView is a white color
for the foreground (text), and dark blue for the background.
My goal is to change it:
* no color at all for the background (not white, because I want to continue
seeing the pattern Qt::DiagCrossPattern with which I have filled some items
in my table).
* making a box appear around selected items (a dotted box), to indicate that
the items are selected.
It seems it is impossible to do with a custom delegate, because there is no
"SelectionRole", or "isSelected" method for a QModelIndex.
And a style sheet is not suited either: if I set the following StyleSheet:
QTableView {
selection-background-color: rgba(255, 255, 255, 0%);
}
, I obtain the result that the selected items are completely white (text and
background), and the patterns filled by my delegate disappear.
It seems to me there are other solutions:
* derive a QStyle?
* derive QTableView and its paintEvent? I am not familiar to this low-level
approach.
What solution is the better? What is its level of difficulty?
Thanks,
Julien
--
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\
9&1+,\'Z4(55l4('])"
"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)
More information about the Qt-interest-old
mailing list