From 1cc421eb250a2fabe55133155a5c5ab8a0e5dd31 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 18 Mar 2014 15:05:48 +0100 Subject: Use parent cursor for QLineEdit's clear button when not shown. Task-number: QTBUG-37548 Change-Id: I8a4eb52f9a5a9551e53dab100f2337cf201d7401 Reviewed-by: Giuseppe D'Angelo --- src/widgets/widgets/qlineedit_p.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/widgets/widgets/qlineedit_p.cpp') diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 9ff77c87de..10689b2fc3 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -309,9 +309,7 @@ QLineEditIconButton::QLineEditIconButton(QWidget *parent) : QToolButton(parent) , m_opacity(0) { -#ifndef QT_NO_CURSOR - setCursor(Qt::ArrowCursor); -#endif + updateCursor(); setFocusPolicy(Qt::NoFocus); } @@ -342,11 +340,19 @@ void QLineEditIconButton::setOpacity(qreal value) void QLineEditIconButton::startOpacityAnimation(qreal endValue) { QPropertyAnimation *animation = new QPropertyAnimation(this, QByteArrayLiteral("opacity")); + connect(animation, &QAbstractAnimation::finished, this, &QLineEditIconButton::updateCursor); animation->setDuration(160); animation->setEndValue(endValue); animation->start(QAbstractAnimation::DeleteWhenStopped); } +void QLineEditIconButton::updateCursor() +{ +#ifndef QT_NO_CURSOR + setCursor(qFuzzyCompare(m_opacity, 1.0) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor()); +#endif +} + void QLineEditPrivate::_q_textChanged(const QString &text) { if (hasSideWidgets()) { -- cgit v1.2.3