diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-05-11 12:29:40 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-05-15 04:59:07 +0200 |
commit | 7bee4e9cb3750be4573e1872f52023081b014500 (patch) | |
tree | a23feb84d75f5e42304d60e1fc228271546a6917 /src/widgets/widgets/qlabel_p.h | |
parent | d26ee69140ac2658fcc5a7a516ad52c2b51a1774 (diff) |
QLabel: lay out text using a text control when label can get focus
QLabel ensures a text control in its focusInEvent, and from that point
on lays the text out using the control. A label with text control will
place the text so that there is space for a cursor and text selection,
resulting in text shifting when a label receives focus without having
had a text control before.
Instead of creating the control only on focusIn, ensure that it's
created for any QLabel that can receive focus.
Change-Id: I26c9df3affa08f2360ad4b94de43bd85e2e2e164
Fixes: QTBUG-84080
Pick-to: 5.15
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/widgets/widgets/qlabel_p.h')
-rw-r--r-- | src/widgets/widgets/qlabel_p.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h index 6b3fbc5f0c..4458df3b3e 100644 --- a/src/widgets/widgets/qlabel_p.h +++ b/src/widgets/widgets/qlabel_p.h @@ -92,9 +92,11 @@ public: void _q_buddyDeleted(); #endif inline bool needTextControl() const { + Q_Q(const QLabel); return isTextLabel && (effectiveTextFormat != Qt::PlainText - || (textInteractionFlags & (Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard))); + || (textInteractionFlags & (Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard)) + || q->focusPolicy() != Qt::NoFocus); } void ensureTextPopulated() const; |