Reputation: 1484
I don't want rows to be highlighted on mouse hover. How to disable this highlighting?
Either remove highlighting at all or change it's color: both solutions are fine.
Upvotes: 1
Views: 1959
Reputation: 3741
You can do it the Delegate way:
#include <QStyledItemDelegate>
class NoHighlightDelegate:public QStyledItemDelegate{
public:
void initStyleOption(QStyleOptionViewItem*option,const QModelIndex&viewIndex)const override{
QStyledItemDelegate::initStyleOption(option,viewIndex);
option->state&=~QStyle::State_MouseOver;}
};
Then set this Delegate to your QTreeView
:
//QTreeView*view;
auto*delegate=new NoHighlightDelegate();
delegate->setParent(view);
view->setItemDelegate(delegate);
And you will not get into the hidden selected line problem.
Upvotes: 2
Reputation: 776
tView->setStyleSheet("QTreeView::item:hover{background-color:rgb(255,255,255);}");
Upvotes: 1