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

Implement QBindableSpy

    XMLWordPrintable

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

        For Gerrit Dashboard: QTBUG-93297
        # Subject Branch Project Status CR V

        Activity

          People

            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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change