C++/QML interaction, lifecycle, ...
-
I created a helper class to upload data from QML, instantiated as an element of a page.
When the upload is finnished, the C++ object emits a
uploadSuccess
signal, which is bound in QML to astack.pop()
action, which make my app crash.By poping the page that holds the instantiated C++ object, am I deleting an object in the call stack ?
As a work-around, I use a
Timer
that is started on theuploadSuccess
and callsstack.pop()
afterward.
I guess there are beter ways to achieve that, but I have no clue how, any suggestion ?Thanks.
T.
-
Yes, StackView owns the items, as stated in the docs.
You can use
Qt.callLater()
doc to defer the call topop()
.Or, if you are stuck on COntrols v1, you can set the StackView to keep objects alive: see destroOnPop property. I think it also (unofficially) works with new controls, but I'm not sure.
-
Use a debugger and find out why your application crashes. I guess your c++ helper is misbehaving
-
@sierdzio said in C++/QML interaction, lifecycle, ...:
Yes, StackView owns the items, as stated in the docs.
You can use
Qt.callLater()
doc to defer the call topop()
.Or, if you are stuck on COntrols v1, you can set the StackView to keep objects alive: see destroOnPop property. I think it also (unofficially) works with new controls, but I'm not sure.
Thanks ! I was actually thinking of doing some queued connection... but didn't know how to do that whith QML,
Qt.callLater()
gives a nice alternative !@GrecKo said in C++/QML interaction, lifecycle, ...:
Use a debugger and find out why your application crashes. I guess your c++ helper is misbehaving
I tried to, but got no symboles to help with the stack trace.