| Thanks for the nice response! > The flexbox does not seem to match the power of QML. For instance, I can have a two-pane view as simple as: I'm a bit confused by this example. When you make the other pane wouldn't you need to define all of its anchors too? It seems like the more standard QML approach to a two-pane is using RowLayout[1]. RowLayout {
anchors.fill: parent
Rectangle {
Layout.fillWidth: true
Text {
text: "pane 1"
}
}
Rectangle {
Layout.fillWidth: true
Text {
text: "pane 2"
}
}
}
I agree this is pretty nice and intuitive, but flexbox makes this problem easy too. <div style="
width: 100%;
height: 100%;
display: flex;
">
<p style="flex: 1">pane 1</p>
<p style="flex: 1">pane 2</p>
</div>
Yes inline css has problems, but I didn't want to scare you away with Tailwind[2] and I think inlined CSS makes this example clearer.> It is easy to reference an anchor of a sibling and other parent elements when needed. It seems like by composing layouts in QML you can avoid a lot of manual anchor setting. Though layouts do have their limits. Is that why you resort to setting anchors manually? Flexbox is much less limited and flexbox layouts compose really well. Do you have examples of UI layouts you feel QML solves intuitively that flexbox can't solve intuitively? > Also, making new components is easy; I can inherit properties of a parent element, add my properties and put them in a file for later reuse is something I use extensively Svelte works the same exact way. Well, except for the part that new components do not inherit from existing components. Svelte and other modern UI frameworks prefer composition over inheritance[3]. Composition allows you to be just as expressive, but without the footguns of inheritance. If you have a specific UI problem you think inheritance solves well, I'd be happy to try and create a matching composition based solution. > Building each component carelessly using whatever mockery to get the look I need and then isolating it with its own namespace is relieving. Svelte uses file based components as well. Each file is its own module in TypeScript/JavaScript. If you have rebuttals or other additional things to add I'd love to hear it! [1] https://doc.qt.io/qt-6/qml-qtquick-layouts-rowlayout.html [2] https://tailwindcss.com/ [3] https://en.wikipedia.org/wiki/Composition_over_inheritance |
I think your example on the flexbox use for two pane view illustrates that well. Although I have no experience of using it I get that the gist of it is the same of a RowLayout. It’s a good abstraction for listing many items of the same kind which need to respond dynamically with the change of window dimensions. But when I really need to place two panes 10px appart or put elements on top of it in the bottome left corner, bottom right corner and align margins of the content within the pane anchoring elements manually is so much easier. I remember when I started to learn QML my first instinct was to find where can I make a table and align elements within it where instead I just needed to use anchors.
The beauty of QML is that I can treat RowLayout and Row as elements written in QML itself. If I recall accurately it is possible to loop through child elements and assign properties to them such as anchors with respect to sibiling elements. The abstraction thus is more fundamental.
> Svelte and other modern UI frameworks prefer composition over inheritance
Inheritance is the right abstraction for the UI elements. For instance I don’t need to predict all properties in advance for my custom bottom implemntion when used in the code. Assuming that all of them are available is quite powerful and allows to experiment in place. This work exceptionally well in QML but not in OOP languages in general. Nevertheless, can you come up with `footguns of inheritance` to which QML is susceptible to?
> Svelte uses file based components as well. Each file is its own module in TypeScript/JavaScript.
This sounds interesting. I will give it a try on someday when I will need to make an UI in HTML.