[Interest] Row(Layout), use spacing as resize handle. How to do that?

Mark Gaiser markg85 at gmail.com
Sun Mar 2 01:35:50 CET 2014


On Thu, Feb 27, 2014 at 12:37 PM, Saether Jan-Arve
<Jan-Arve.Saether at digia.com> wrote:
> First, I would consider using SplitView.
>
> If that's not an option, I'm curious why you want to use a layout, and which of its features you want. Specifically, I'm curious to know what behavior you expect when a handle is resized.
> Should it redistribute all items to the left and all items to the right of the handle?
> Then, it's really two layouts (one layout on each side of the handle) that you would have to temporarily create and destroy each time a handle is dragged.
>
> It sounds quite complex, and I'm not sure if you want to go that route, since it would involve injecting layouts in the hierarchy, setting temporary implicit sizes on all items to not cause sudden jumps when starting a drag.
>
> At this point I cannot see a clean and simple solution to this, and I don't want to speculate further unless you are really convinced ;)
>
> Jan Arve

Right,

Now i've actually tested the SplitView :)
And it behaves differently compared to RowLayout. In a bad way.
In a row layout something like:

        RowLayout {
            anchord.fill: parent

            Rectangle {
                Layout.fillWidth: true
                Layout.fillHeight: true
                color: "red"
            }

            Rectangle {
                Layout.fillWidth: true
                Layout.fillHeight: true
                color: "green"
            }
        }

results in red and green being evenly distributed.
In a SplitView that is not the case. There the first rectangle (the
red one) is getting all the space. Green is on the right and all you
see is the splitter to "drag it in".
Just change "RowLayout" to "SplitView" and you will see what i mean.

Bug report time?

>
>> -----Original Message-----
>> From: interest-bounces+jan-arve.saether=digia.com at qt-project.org
>> [mailto:interest-bounces+jan-arve.saether=digia.com at qt-project.org] On
>> Behalf Of Mark Gaiser
>> Sent: 27. februar 2014 03:01
>> To: Qt Interest
>> Subject: [Interest] Row(Layout), use spacing as resize handle. How to
>> do that?
>> Hi,
>>
>> It seems like i'm trying to make something that simply isn't possible
>> with the currently shipping QtQuick components. So i'm trying to make
>> a custom version.
>>
>> Take the following example code as base:
>>
>> ============================================
>> import QtQuick 2.0
>> import QtQuick.Layouts 1.1
>>
>> RowLayout {
>>     width: 800
>>     height: 600
>>     spacing: 0
>>
>>     Rectangle {
>>         color: "red"
>>         width: 100
>>         Layout.fillHeight: true
>>     }
>>
>>     Rectangle {
>>         color: "orange"
>>         width: 10
>>         Layout.fillHeight: true
>>     }
>>
>>     Rectangle {
>>         Layout.fillWidth: true
>>         Layout.fillHeight: true
>>         color: "green"
>>     }
>>
>>     Rectangle {
>>         color: "orange"
>>         width: 10
>>         Layout.fillHeight: true
>>     }
>>
>>     Rectangle {
>>         Layout.fillWidth: true
>>         Layout.fillHeight: true
>>         color: "blue"
>>     }
>> }
>> ============================================
>>
>> This example has no interaction, obviously :)
>>
>> What i'm trying to make is use the spacing between elements as resize
>> handles. By default (in Row and RowLayout that is not possible since
>> it's just a real value setting. It's not a delegate.
>>
>> So i have a few different ways in making this. Nether seems to work
>> neatly though.
>>
>> 1. Use anchors where i anchor elements to the resize handle. This
>> isn't very feasible because the resulting code uses lots of anchor
>> magic and is just a mess to make easily extendable with more elements.
>> Something that is easy for the RowLayout.
>>
>> 2. Use RowLayout and add my own "resize handles". Seems like the
>> cleanest solution but doesn't work in practice because moving the
>> handles (the ones in orange in the example) don't update the RowLayout
>> itself.. So nothing besides the handle changes.
>>
>> Now i'm searching for a hybrid solution.
>> I want to create something with the simplicity of the example provided
>> above but with the functionality as if i where using anchors. But i
>> don't quite know where to start. Do i need to make a custom QQuickItem
>> class? Or do i need to play with some other class? If so, which one(s)?
>>
>> Cheers,
>> Mark
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list