Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QState assignProperty and object pointer lifetime
qtradar last edited by
Can anyone tell me how QState's assignProperty(QObject *, const char *, const QVariant &) method handles objects that are no longer in scope?
For example, I would like to set the enabled property of a button in a QDialog from the global state machine in my application. The assignProperty(button, "enabled", false) statement is executed every time the dialog is opened, as the dialog is newly instantiated every time. The issue is, that with the above statement active, my application sometimes crashes after opening the dialog a few times. It seems that assignProperty() is sometimes still trying to set the property of the already deleted previous buttons. Could this be possible? If so, is there a way to remove an assignProperty() instruction from a state without deleting and recreating the entire state?