Bug 435066

Summary: FormLayout items cannot be made to fill width without triggering compact mode
Product: [Frameworks and Libraries] frameworks-kirigami Reporter: Rinigus <rinigus.git>
Component: generalAssignee: Marco Martin <notmart>
Status: CONFIRMED ---    
Severity: normal CC: nate, rinigus.git
Priority: NOR    
Version First Reported In: 5.77.0   
Target Milestone: Not decided   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Rinigus 2021-03-28 14:30:17 UTC
SUMMARY

It seems to be impossible to make Kirigami.FormLayout to fill the full width of the page. In practice, in wide mode, it tends to occupy some space in the middle of the page instead of spreading itself to fill it.

Example:

In Kirigami Gallery:

        Kirigami.FormLayout {
            id: layout
            Layout.fillWidth: true

is ignored. If you insert 

            TextField {
                Layout.fillWidth: true
            }

in front of it, that one will fill the column fully, as long as it is outside of the form.

As it is, it does not allow to use available space even if instructed to do so.


SOFTWARE/OS VERSIONS
Linux/Kirigami: 5.77.0
Qt Version: several, currently on 5.15
Comment 1 Nate Graham 2021-03-31 16:46:07 UTC
It does fill the width, but it centers the content within the invisible box that it's filling, rather than stretching everything to fit. That's the point of it: to create a mostly-centered layout. If you want controls to literally fill the entire width, a FormLayout is probably not the right layout tool to use.
Comment 2 Rinigus 2021-03-31 16:56:52 UTC
OK, so, already by design it does not allow to make a form that would fill the available width if the child elements signal that they wish to do so. Right?

Any way to regulate the amount of area that is used in practice for showing data and fraction used for borders during centering?
Comment 3 Nate Graham 2021-03-31 16:59:23 UTC
Could you supply an example, or maybe a code snippet that shows what you're trying to do?
Comment 4 Rinigus 2021-03-31 17:11:40 UTC
I want to have forms as in "Preferences" in Pure Maps and OSM Scout Server. In these forms, I would like to show

Tag | setting widget
      description text

That should fill the width of the page to make it as simple as possible to interact with the widget. Right now, if I force the width of the form, I get alignment errors as in

https://github.com/rinigus/osmscout-server/issues/355

So, it is obvious that I shouldn't specify width. 

Minimal example I could come up with was in the first post, but let me rephrase it. 

If I take Kirigami Gallery and insert in front of 

https://github.com/KDE/kirigami-gallery/blob/4b6cf719c9dbdc0e429e6ef50862cd1c0e233d47/src/data/contents/ui/gallery/FormLayoutGallery.qml#L45

Layout.fillWidth: true, so it will become

            TextField {
                Kirigami.FormData.label: "Label:"
                Layout.fillWidth: true
            }

I would expect FormLayout to fulfill the intention:

1: make itself as wide as possible. It is also asked by the Form in that demo above;

2: make text field as wide as possible.

Please let me know if something is not clear and I should provide better description.
Comment 5 Nate Graham 2021-03-31 17:51:06 UTC
What you can do is choose one element inside the form to be the "widener" element and set `implicitWidth: [something long]` on it, which will make it stretch out the layout horizontally. Then any other elements that need the same width can have `implicitWidth: [widenerElement].implicitWidth`
Comment 6 Rinigus 2021-03-31 18:14:51 UTC
Yes, I can do that. But in this case I will have to figure out the correct width of that widener element. Something which is not super trivial as you have to take into account all labels (on the left) and spacing between label corresponding element. Somehow, I've got an impression that all this work has been done already and is a part of the FormLayout.

Now, when in narrow mode, the form does actually fill full width. Which is consistent with the expectations.
Comment 7 Nate Graham 2021-03-31 19:18:40 UTC
I see. Yeah, maybe this is a reasonable request after all.