From a34e9ebc1b908d31ba645688a8b0e9e53c2d3c6e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 6 May 2015 17:00:21 +0200 Subject: QLineEdit: show the clear button if it gets enabled after setting a text We were fetching "lastText" too late, and setting the opacity of the clear button to 0. Change-Id: I82c2aea7dab4af4424fb57e12f78d07a0374457e Task-number: QTBUG-45518 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qlineedit_p.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 6a41c3791f..ad3a92d35a 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -440,6 +440,10 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE Q_Q(QLineEdit); if (!newAction) return 0; + if (!hasSideWidgets()) { // initial setup. + QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); + lastTextSize = q->text().size(); + } QWidget *w = 0; // Store flags about QWidgetAction here since removeAction() may be called from ~QAction, // in which a qobject_cast<> no longer works. @@ -456,10 +460,6 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE toolButton->setDefaultAction(newAction); w = toolButton; } - if (!hasSideWidgets()) { // initial setup. - QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); - lastTextSize = q->text().size(); - } // If there is a 'before' action, it takes preference PositionIndexPair positionIndex = before ? findSideWidget(before) : PositionIndexPair(position, -1); SideWidgetEntryList &list = positionIndex.first == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets; -- cgit v1.2.3