Cruz
27th January 2009, 19:01
Hi!
I have a widget that allows the user to manipulate data with lots of QSpinBoxes. There is 20 of them! The data object is loaded by drag and drop, then all the spinboxes change to the values contained by the object. When the user tinkers with the values, the data object should be changed immidiately.
The solution I came up with is like this:
Connect the valueChanged(int) signals from all spinboxes to one inputValuesChanged() slot, that will sweep through all spinboxes, take their current values one by one and overwrite the fields of the data object.
The positive side is that I only have to write one slot. The negative side, which is not so bad, is that I change 20 fields each time something changes, although I would only need to change 1. And the really negative is side is this:
When I load the data object by drag and drop, I sweep through the fields of it and write the values into the spinboxes. As soon as the first spinbox is touched, the signal is fired and the rest of the data object is overwritten with whatever crap is currently in the spinboxes. So when I load an object, first I need to disconnect all the spinboxes, then overwrite their values and then connect them again. Blah. Unfortunately unlinke LineEdits, SpinBoxes don't have a signal that is not fired when the value is changed programatically.
Can anyone suggest a more elegant solution
Thanks
Cruz
I have a widget that allows the user to manipulate data with lots of QSpinBoxes. There is 20 of them! The data object is loaded by drag and drop, then all the spinboxes change to the values contained by the object. When the user tinkers with the values, the data object should be changed immidiately.
The solution I came up with is like this:
Connect the valueChanged(int) signals from all spinboxes to one inputValuesChanged() slot, that will sweep through all spinboxes, take their current values one by one and overwrite the fields of the data object.
The positive side is that I only have to write one slot. The negative side, which is not so bad, is that I change 20 fields each time something changes, although I would only need to change 1. And the really negative is side is this:
When I load the data object by drag and drop, I sweep through the fields of it and write the values into the spinboxes. As soon as the first spinbox is touched, the signal is fired and the rest of the data object is overwritten with whatever crap is currently in the spinboxes. So when I load an object, first I need to disconnect all the spinboxes, then overwrite their values and then connect them again. Blah. Unfortunately unlinke LineEdits, SpinBoxes don't have a signal that is not fired when the value is changed programatically.
Can anyone suggest a more elegant solution
Thanks
Cruz