[Interest] Awkwardness of delegates in heterogenous ListViews

Michael Brasser michael.brasser at live.com
Thu Jun 9 19:07:03 CEST 2016


Hi,


For reference there is a long standing suggestion to add built-in support for multiple delegates (https://bugreports.qt.io/browse/QTBUG-26681). This doesn't help at all in the short term, but might be of interest (and is a great place to record suggestions if you have any ideas/requirements for what such support should look like).


Regards,

Michael

________________________________
From: Interest <interest-bounces+michael.brasser=live.com at qt-project.org> on behalf of Elvis Stansvik <elvstone at gmail.com>
Sent: Wednesday, June 8, 2016 8:32:41 AM
To: interest at qt-project.org Interest
Subject: [Interest] Awkwardness of delegates in heterogenous ListViews

Hi all,

I'm currently using a "type" role in my items and then a Loader as
delegate, to give a level of indirection and let me choose the actual
delegate based on the "type" of the item.

This explains it better (from my ListView):

        delegate: Loader {
            sourceComponent: {
                switch (type) {
                case "color":
                    return colorDelegate
                case "flag":
                    return flagDelegate
                ...
                }
            }

            Component {
                id: colorDelegate

                ColorDelegate { }
            }

            Component {
                id: flagDelegate

                FlagDelegate { }
            }

            ...
        }

What I don't like with this approach is that inside my delegates, e.g.
ColorDelegate.qml, I have to use parent.ListView.view.model to get a
reference to the model (needed for editing operations). The use of
"parent" here assumes a certain layout, but I see no other way :(

How have others solved the issue of delegates for heterogenous lists?

Best regards,
Elvis
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160609/e8203dd3/attachment.html>


More information about the Interest mailing list