diff options
author | mae <qt-info@nokia.com> | 2009-10-02 10:30:58 (GMT) |
---|---|---|
committer | mae <qt-info@nokia.com> | 2009-10-02 10:32:58 (GMT) |
commit | cbb94c29b065222e7cd8a5b55b018f14d3b79984 (patch) | |
tree | 1da2a65b6859261f59ad581bdb85f30865500c57 /src | |
parent | b0b8d8f7a65e31c0edabe7fbe6ee91bb62a67d7c (diff) | |
download | Qt-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.cpp | 13 |
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); } |