diff options
author | Kaj Grönholm <kaj.gronholm@qt.io> | 2023-04-05 11:19:31 +0300 |
---|---|---|
committer | Kaj Grönholm <kaj.gronholm@qt.io> | 2023-05-26 11:06:16 +0300 |
commit | bdb7bc0543abe6870f3d24887b5dd0d94930d2d6 (patch) | |
tree | 97e0a6a2e19b60ed986cd9754755c79d2a05dace /src/quick/items/qquicktextedit_p_p.h | |
parent | 064aa8127ca4be856f573c25d94d0cf86215a1c4 (diff) |
QQuickScrollView and QQuickTextEdit: Fix binding loops
If the content item of a ScrollArea is a height <-> width dependent
item, like a TextEdit, a change in the height of the content, may
trigger the vertical scrollbar to become visible, (if the content height
is bigger than the ScrollArea's height). This in turn causes the right
padding of the ScrollArea to change, to make place for the scrollbar,
causing in this way a content resize again, giving us a binding loop
on the Scrollbar's visible property and the ScrollView's
'implicitHeight'.
To get rid of the binding loop on the 'implicitHeight' property, check
if the TextEdit's updateSize() has already been called, and if so, don't
emit its contentSizeChanged() signal again.
In order to get rid of the binding loop on the Scrollbars' 'visible'
property, introduce two new properties: effectiveScrollBarWidth and
effectiveScrollBarHeight which represent the actual width/height of
the scrollbars. Set this property dependent on the scrollbar's policy,
visibility, and the scrollview's content size and make sure to update
whenever any of these changes. Also, follow the same pattern as above
and don't emit the signal twice if on a recursive call.
[ChangeLog][Controls][ScrollView] Added effectiveScrollBarWidth and
effectiveScrollBarHeight which hold the effective sizes of scrollbars.
Fixes: QTBUG-97974
Change-Id: I3d915eae53881d000769de1824c3908c7acd5c6b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quick/items/qquicktextedit_p_p.h')
-rw-r--r-- | src/quick/items/qquicktextedit_p_p.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h index db07462a5a..087a18734a 100644 --- a/src/quick/items/qquicktextedit_p_p.h +++ b/src/quick/items/qquicktextedit_p_p.h @@ -95,7 +95,7 @@ public: , focusOnPress(true), persistentSelection(false), requireImplicitWidth(false) , selectByMouse(true), canPaste(false), canPasteValid(false), hAlignImplicit(true) , textCached(true), inLayout(false), selectByKeyboard(false), selectByKeyboardSet(false) - , hadSelection(false), markdownText(false) + , hadSelection(false), markdownText(false), inResize(false) { } @@ -202,6 +202,7 @@ public: bool selectByKeyboardSet:1; bool hadSelection : 1; bool markdownText : 1; + bool inResize : 1; static const int largeTextSizeThreshold; }; |