Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-93297

Implement QBindableSpy

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • None
    • None

      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)).

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            fabiankosmale Fabian Kosmale
            ivan.solovev Ivan Solovev
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There is 1 open Gerrit change