Hacker News new | ask | show | jobs
by saidinesh5 11 days ago
I think Qt/QML really reached hit sweet spot for me when it comes to describing UIs (ignore if any syntax errors, doing this from memory):

For eg. compare this:

``` Window { textColor: "slategray" property int v: 40

    ColumnLayout {
        id: layout
        anchors.fill: parent
        spacing: 20

        Text {
            id: number
            Layout.alignment: Qt.AlignHCenter
            font.pixelSize: 70
            text: v
        }

        ProgressBar {
            id: progressBar
            Layout.alignment: Qt.AlignHCenter
  
            value: v/100
            color: v < 50 ? "dodgerblue" : "turquoise"
        }
    }

    MouseArea {
        anchors.fill: parent
        onClick: v = (v+20)%100
    }
} ```

with Declare:

``` App [ textColor = slategray,

    group: View [ x = center, y = center, width = 80%,
        layout: SimpleLayout [ axis = y, spacing = 20 ],

        number: Text [ width = 100%, textAlign = center,
            fontSize = 70, fontWeight = bold, text = { "" + v } ],

        bar: Gauge [ width = 100%, value = { v },
            tint = { v < 50 ? cool : warm }, accessibilityLabel = "v" ],

        hint: Text [ width = 100%, textAlign = center,
            text = "click anywhere to change v" ]
        ],

    v: number = 40,
    cool: Color = dodgerblue,
    warm: Color = turquoise,

    onClick() { v = (v + 20) % 100 }
    ]
```
6 comments

It lives on in Slint. The syntax is inspired to QML, but statically typed and compiled to native code (no JS engine, no browser). Can be used from different programming languages. https://github.com/slint-ui/slint
I actually used to follow Slint back when we used Qt at $DAY_JOB! I learned quite a bit about compilers looking at your repo back then..
QML was really something special. I’m sad that type of syntax never really caught on in the wider UI world.
Yes. I love Qt/QML. Nothing has replaced it for me since. I find android/ios too hard to read, until Jetpack compose came along and even then. Dart is better
It's so interesting how different frameworks appeal to different kinds of people. For me personally, I regret every second I've ever spent writing glue code. The whole signals/slots paradigm killed my desire to use Qt every time I tried it.
Sad that it's similar slow and memory hungry like winui (qtwidget app use 10mb => qml 100mb).

Additional to it it may have more fps, but feels less snappy.

I still use it as it's better than electron, but still makes me sad.

As good as QML / QtQuick is, I feel like it makes it very easy to create slower applications by creating too many objects, and too many property bindings.. A lot of QtQuick widget libraries made all kinds of mistakes and you end up really sluggish desktop applications.. even though - the fps counter shows 60 fps..

But I have also seen really well optimized QtQuick applications that ran at 60 fps on a single core imx6 while playing video, applying all kinds of effects on the video...

Hm. Its great.

I'm happy enough the with xml-based tsx - if only to differentiate between declared structure v.s. expressions.

Especially (with what I've seen briefly) of Solid v2.

But I'm sure I could get used to the above quick.

My thinking exactly https://ljos.dev/
Yeah I had a lot of fun building pretty stuff with QML. I always want to build my UI in it but never have a good fit.