Bug 396450

Summary: KCollapsibleGroupBox: wrong position in parent layout if there is a QLabel with word-wrap
Product: [Frameworks and Libraries] frameworks-kwidgetsaddons Reporter: Elvis Angelaccio <elvis.angelaccio>
Component: generalAssignee: Christoph Feck <cfeck>
Status: CONFIRMED ---    
Severity: normal CC: a.samirh78, kde, kdelibs-bugs-null, nate
Priority: NOR    
Version First Reported In: 5.47.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Self-contained test case for the issue
Expected layout
Actual layout

Description Elvis Angelaccio 2018-07-12 20:37:22 UTC
Created attachment 113904 [details]
Self-contained test case for the issue

If a KCollapsibleGroupBox contains a QLabel with word-wrapping enabled, it will be wrongly positioned in its parent layout.

This issue seems to be called by the setFocusPolicy() call in overrideFocusPolicyOf().

Not sure whether the bug is in KCollapsibleGroupBox or in Qt.
Comment 1 Elvis Angelaccio 2018-07-12 20:39:17 UTC
Created attachment 113905 [details]
Expected layout
Comment 2 Elvis Angelaccio 2018-07-12 20:40:01 UTC
Created attachment 113906 [details]
Actual layout
Comment 3 Nate Graham 2018-07-13 16:12:09 UTC
Patch available: https://phabricator.kde.org/D13570
Comment 4 Elvis Angelaccio 2018-08-04 15:07:23 UTC
Git commit e8519d6af2ad2b9c342a270a915e613bc88dff47 by Elvis Angelaccio.
Committed on 04/08/2018 at 15:02.
Pushed by elvisangelaccio into branch 'master'.

Add workaround for labels with word-wrapping

Summary:
It's not clear why, but the combination of a word-wrapped QLabel with
the `setFocusPolicy()` call in `overrideFocusPolicyOf()` seems to break
the positioning of the groupbox in its parent layout.

Until we understand where the bug is and how to fix it, we can toggle
the groupbox twice when we detect that a QLabel with word-wrapping
enabled has been added as child. Not clear why (again), but this fixes
(or at least hides) the issue.

Test Plan: Apply the patch, then run `kcollapsiblegroupboxtest` with/without the workaround compiled in.

Reviewers: davidedmundson

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D13570

M  +12   -0    src/kcollapsiblegroupbox.cpp
M  +6    -0    tests/kcollapsiblegroupboxtest.cpp

https://commits.kde.org/kwidgetsaddons/e8519d6af2ad2b9c342a270a915e613bc88dff47
Comment 5 Ahmad Samir 2021-08-25 23:15:36 UTC
I tested this, and with and without the above commit the issue seems to be fixed.