summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-10-02 10:30:58 (GMT)
committermae <qt-info@nokia.com>2009-10-02 10:32:58 (GMT)
commitcbb94c29b065222e7cd8a5b55b018f14d3b79984 (patch)
tree1da2a65b6859261f59ad581bdb85f30865500c57 /src
parentb0b8d8f7a65e31c0edabe7fbe6ee91bb62a67d7c (diff)
downloadQt-cbb94c29b065222e7cd8a5b55b018f14d3b79984.zip
Qt-cbb94c29b065222e7cd8a5b55b018f14d3b79984.tar.gz
Qt-cbb94c29b065222e7cd8a5b55b018f14d3b79984.tar.bz2
Clear text selection in QLabel when it is losing focus
The change implements the same logic for QLabel which QLineEdit (and implicitely QSpinBox and QComboBox) already had. Reviewed-by: Simon Hausmann
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/qlabel.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp
index 5ff323a..5ba0571 100644
--- a/src/gui/widgets/qlabel.cpp
+++ b/src/gui/widgets/qlabel.cpp
@@ -886,7 +886,18 @@ void QLabel::focusInEvent(QFocusEvent *ev)
void QLabel::focusOutEvent(QFocusEvent *ev)
{
Q_D(QLabel);
- d->sendControlEvent(ev);
+ if (d->control) {
+ d->sendControlEvent(ev);
+ QTextCursor cursor = d->control->textCursor();
+ Qt::FocusReason reason = ev->reason();
+ if (reason != Qt::ActiveWindowFocusReason
+ && reason != Qt::PopupFocusReason
+ && cursor.hasSelection()) {
+ cursor.clearSelection();
+ d->control->setTextCursor(cursor);
+ }
+ }
+
QFrame::focusOutEvent(ev);
}