Qt World Summit: Submit your Presentation

Multiple property change events in the same time ?

  • Hi to all,

    If I have a property that needs some trick when the value changes i.e. saving its new value somewhere the most reliable thing to do is to manage the assignement in a onPropertyChange: event.

    What happens when I have 5 or 10 properties that should be managed? What I am asking is if there is a way to manage a single event including multiple properties so when at least one of these changes the event is fired and I can manage the changes as the program logic need.

    The actual simple solution that I have found is to chain a couple of events in the following way:
    // Set a global signal
    signal somethingChangeProp

    // Set the default values for the properties
    property string valueA: "aaa"
    property string valueB: "bbb"
    property string valueC: "ccc"

    // When a property changes always the same signal is called
    onValueAChanged: somethingChangeProp()
    onValueBChanged: somethingChangeProp()
    onValueCChanged: somethingChangeProp()

    onSomethingChangeProp: {
    // js code to manage the values of the three properties, save them etc.

    Is there a more efficient method ?

Log in to reply