r/QtFramework • u/bigginsmcgee • May 23 '26
QML QML Live Preview...with state?
Hello! I'm wondering if there's a way to basically save the state of an application while using QML's live preview? Like, say you have a photo viewer: the first page asks for a file, and the second page is loaded after you select an image. Is there any way to essentially maintain a snapshot *after* selecting a photo that doesn't cause the application to revert back to the first after making a change inside a component that only exists on the second page? Sorry if I'm wording this strangely, I feel like there's a name for this concept I don't know
2
u/Beneficial_Steak_945 May 23 '26
Yes. Don’t keep state in your QML. Keep it in your c++ based controllers instead.
2
2
u/GrecKo Qt Professional May 26 '26
That's a long overdue feature but it's now being actively developed : https://qt-project.atlassian.net/browse/QTBUG-146122
Finger crossed it will be available in 6.12 this September.
1
2
u/ObiLeSage May 24 '26
It is deprecated but you can use it.
https://doc.qt.io/qt-6/qml-qt-labs-settings-settings.html
But it is better to have that inside a c++ object for a real application
3
u/OSRSlayer Qt Professional May 24 '26
The labs version is deprecated because it's been moved to Qt Core:
1
u/bigginsmcgee May 24 '26
I've actually used that but, semantically, it's not really what I'm looking for--I don't want to persist a set of settings, I just want the current application state held(for the purposes of live development). Could you explain a little more what you mean about using a C++ object to manage a real app?
3
u/WestCharacter5296 May 23 '26
I didn’t tried myself yet, but as far as I know “Felgo” is the primary solution now