News for hackers. Stuff that matters.
Re:Understanding the Layout Process in Qt Widgets by throwup238 on Saturday September 07, 2024 @11:07AM (#41474314)
It’s very easy to implement a naive version. It only took me a few hours with the help of GPT/Claude and most of that was figuring out how to save and restore all window positions.

All it is is Rust’s notify listening for any changes in my QML directory and calling a C++ function on QQmlEngine: https://pastebin.com/08QKu84H

It'll require a bit more work once I'm loading multiple root QML files but for now it works great. It doesn't explicitly restore any state, however, but I store most of my UI state in Settings and a custom component that syncs arbitrary JSON values to Sqlite so the previous state is automatically restored when the QML is reloaded.

Re:Understanding the Layout Process in Qt Widgets by neobrain on Sunday September 08, 2024 @04:36PM (#41482998)
Ah, I somehow assumed more magic would be needed, but indeed it's really as simple as deleting the top-level widget and recreating it. And then repopulating the properties is what gives it the illusion of being dynamically live-patched.

I'll take a shot at implementing this in some of my code as well. Thanks!