Results 1 to 5 of 5

Thread: QState: how to add and/or remove properties added with QState::assignProperty?

  1. #1

    Default QState: how to add and/or remove properties added with QState::assignProperty?

    Hi,
    If I want to know which properties are added with:
    Qt Code:
    1. void QState::assignProperty ( QObject * object, const char * name, const QVariant & value )
    To copy to clipboard, switch view to plain text mode 
    Currently (qt 4.6.2) I've not found how to do it.

    Some times could be useful also remove them...

    Any idea?

    Nicola

  2. #2
    Join Date
    Apr 2009
    Posts
    36
    Thanks
    1
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QState: how to add and/or remove properties added with QState::assignProperty?

    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/statemac...ore-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.

  3. #3
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QState: how to add and/or remove properties added with QState::assignProperty?

    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.

    Qt Code:
    1. void QState::assignProperty(QObject *object, const char *name,
    2. const QVariant &value)
    3. {
    4. Q_D(QState);
    5. if (!object) {
    6. qWarning("QState::assignProperty: cannot assign property '%s' of null object", name);
    7. return;
    8. }
    9. for (int i = 0; i < d->propertyAssignments.size(); ++i) {
    10. QPropertyAssignment &assn = d->propertyAssignments[i];
    11. if ((assn.object == object) && (assn.propertyName == name)) {
    12. assn.value = value;
    13. return;
    14. }
    15. }
    16. d->propertyAssignments.append(QPropertyAssignment(object, name, value));
    17. }
    To copy to clipboard, switch view to plain text mode 

    Why don't you create a new state and replace the old one instead of trying to change it?

    Johannes

  4. #4

    Default Re: QState: how to add and/or remove properties added with QState::assignProperty?

    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

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QState: how to add and/or remove properties added with QState::assignProperty?

    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".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Monitor a new added File
    By designer.software in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2010, 09:50
  2. rotate in QState
    By estel in forum Qt Programming
    Replies: 0
    Last Post: 21st October 2009, 12:39
  3. Connecting dynamically added properties
    By stefkeB in forum Qt Programming
    Replies: 1
    Last Post: 5th December 2008, 15:19
  4. Data not being added to my QTableView?
    By steg90 in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2007, 14:20
  5. How to remove widget added in runtime?
    By jiveaxe in forum Qt Programming
    Replies: 7
    Last Post: 2nd November 2007, 10:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.