Hi,
you can simple use QSS, for example:
QTableView::item:selected {
background: #6a6ea9;
}
On 05.02.2016 18:34, Murphy, Sean wrote:
I’m still struggling with how to customize the selection color for
items on a QTableView (previously posted as
http://lists.qt-project.org/pipermail/interest/2016-January/020760.html).
I currently color the rows with custom colors based on the data being
shown in each row in my model’s data(const QModelIndex &currIndex, int
role) when role == Qt::BackgroundRole.
I’d like for that color to persist when the user selects a row; so
either I want the selection to only paint the dotted line around the
entire row without changing the background color to the OS’s default
selection color, or I’d also be fine if there was no change at allwhen
the row is selected. The only reason I allow rows to be selected at
all is apparently that is required to allow the user to start a drag
on a row when they are attempting to reorder the rows in the table. I
can’t seem to figure out where this needs to happen.
Correct me if I’m wrong on any of the following:
1.I can’t use a stylesheet because the colors are different on a
row-by-row basis
2.I don’t think the selection background color is controlled anywhere
in the model?
3.I really don’t have any need for the user to be able to select
anything – the table is meant to be a read-only display of data -
EXCEPT it appears that being able to select items is a requirement for
the drag-n-drop system?
Any pointers?
Sean
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest