Details
-
Task
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
None
Description
New bindable properties do not require signals. Because of that, checking how many times the value has actually changes becomes a little verbose.
On the C++ side you need to implement something like this:
int counter = 0;
auto handler = object.bindableProperty().onValueChanged([&counter]() { ++counter; });
Q_UNUSED(handler)
And the situation becomes even more annoying, if one needs to do it on QML side. I could only solve it by introducing 2 extra properties:
property real direction: testingSource.position.direction
property int directionChangedCount: 0
onDirectionChanged: {
++directionV1ChangedCount
}
Suggestion: let's implement a QBindableSpy that would behave very much like QSignalSpy, but do not require a signal.
The actual API can be discussed, but as I see it now, it should be possible to do at least two things:
- Query the total amount of changes (like QSignalSpy::count);
- Query the individual value by index (like QSignalSpy::at(index)).
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-93297 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
351138,1 | WIP: Add QPropertySpy | dev | qt/qtbase | Status: NEW | -2 | 0 |