From b56c8e1428a6159e9fd2f17458dc2fa4c7f701d5 Mon Sep 17 00:00:00 2001 From: rekols Date: Sat, 22 Jun 2019 20:53:21 +0800 Subject: [PATCH] adjust ui --- src/serviceitemdelegate.cpp | 8 +++++++- src/serviceview.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/serviceitemdelegate.cpp b/src/serviceitemdelegate.cpp index af66ce1..e514d15 100644 --- a/src/serviceitemdelegate.cpp +++ b/src/serviceitemdelegate.cpp @@ -22,7 +22,13 @@ void ServiceItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o const int column(index.column()); painter->setRenderHint(QPainter::Antialiasing); - painter->setPen(QColor("#303030")); + + if (option.state & QStyle::State_Selected) { + painter->fillRect(option.rect, QColor("#D0E8FA")); + painter->setPen(QColor("#000000")); + } else { + painter->setPen(QColor("#303030")); + } // painting each column item. if (column == 0) { diff --git a/src/serviceview.cpp b/src/serviceview.cpp index 424cb99..d95431a 100644 --- a/src/serviceview.cpp +++ b/src/serviceview.cpp @@ -8,7 +8,7 @@ ServiceView::ServiceView(QWidget *parent) : QTreeView(parent) { setEditTriggers(QAbstractItemView::NoEditTriggers); - setSelectionMode(QAbstractItemView::NoSelection); + setSelectionMode(QAbstractItemView::SingleSelection); setSelectionBehavior(QAbstractItemView::SelectRows); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);