Highlight background of label

This commit is contained in:
craig.p.drummond
2014-01-29 19:18:04 +00:00
committed by craig.p.drummond
parent 4e2e6ca759
commit 520ebbe6d4

View File

@@ -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) {