View Full Version : QState: how to add and/or remove properties added with QState::assignProperty?
breezeight
22nd March 2010, 16:29
Hi,
If I want to know which properties are added with:
void QState::assignProperty ( QObject * object, const char * name, const QVariant & value )
Currently (qt 4.6.2) I've not found how to do it.
Some times could be useful also remove them...
Any idea?
Nicola
bmhautz
22nd March 2010, 18:32
I'm not completely sure what you're asking, but here's an example of using properties with the state machine framework: http://qt.nokia.com/doc/4.6/statemachine-api.html#using-restore-policy-to-automatically-restore-properties. As far as removing them, it doesn't seem like there is an API to specifically remove properties, but you could take a look at the restore properties section listed in the above documentation.
JohannesMunk
24th March 2010, 17:03
I think he wants to edit the list of properties that a specific state sets.
A quick look into QState.cpp reveals, that the list of properties to be set is stored in the private object. As far as I can see, there are no other access-members to d->propertyAssignments.
void QState::assignProperty(QObject *object, const char *name,
const QVariant &value)
{
Q_D(QState);
if (!object) {
qWarning("QState::assignProperty: cannot assign property '%s' of null object", name);
return;
}
for (int i = 0; i < d->propertyAssignments.size(); ++i) {
QPropertyAssignment &assn = d->propertyAssignments[i];
if ((assn.object == object) && (assn.propertyName == name)) {
assn.value = value;
return;
}
}
d->propertyAssignments.append(QPropertyAssignment(obj ect, name, value));
}
Why don't you create a new state and replace the old one instead of trying to change it?
Johannes
breezeight
25th March 2010, 09:52
Yes It's what I mean. I could replace a state but I had to restore also all the transitions... a lot of work. But it seem the only way to do what I need, thank you!
Nicola
wysota
25th March 2010, 10:32
To me it seems that if you wish to change the properties for a particular state in reality the new set of properties and the old one correspond to two different states. You can make a state with two substates each holding a different set of property values and decide which substate will be entered when the parent state is entered based on which set of properties you want to consider "active".
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.