From 520ebbe6d4227f19cc3aaee00c682be366ec4310 Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Wed, 29 Jan 2014 19:18:04 +0000 Subject: [PATCH] Highlight background of label --- widgets/itemview.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/widgets/itemview.cpp b/widgets/itemview.cpp index 98a4eac0c..b10385b21 100644 --- a/widgets/itemview.cpp +++ b/widgets/itemview.cpp @@ -1148,8 +1148,9 @@ bool ItemView::eventFilter(QObject *o, QEvent *e) title->setProperty(constPressesProperty, false); break; case QEvent::HoverEnter: { - QColor col=palette().highlight().color(); - title->setStyleSheet(QString("QLabel { color : rgb(%1, %2, %3); }").arg(col.red()).arg(col.green()).arg(col.blue())); + QColor bgnd=palette().highlight().color(); + title->setStyleSheet(QString("QLabel{background:rgb(%1,%2,%3,48);}") + .arg(bgnd.red()).arg(bgnd.green()).arg(bgnd.blue())); break; } case QEvent::HoverLeave: @@ -1279,7 +1280,9 @@ void ItemView::activateItem(const QModelIndex &index, bool emitRootSet) if (text.isEmpty()) { text=index.data(Qt::DisplayRole).toString(); } - title->setText(text); + // Add padding so that text is not right on border of label widget. + // This spacing makes the mouse-over background change look nicer. + title->setText(QLatin1String(" ")+text); listView->setRootIndex(index); itemModel->setRootIndex(index); if (emitRootSet) {