Use parent cursor for QLineEdit's clear button when not shown.

Task-number: QTBUG-37548
Change-Id: I8a4eb52f9a5a9551e53dab100f2337cf201d7401
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Friedemann Kleint 2014-03-18 15:05:48 +01:00 committed by The Qt Project
parent e07684294d
commit 1cc421eb25
2 changed files with 12 additions and 3 deletions

View File

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

View File

@ -89,6 +89,9 @@ public:
protected:
void paintEvent(QPaintEvent *event);
private slots:
void updateCursor();
private:
void startOpacityAnimation(qreal endValue);