Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Monitoring an object changed asynchronously by a Callback function
Forum Update on Monday, May 27th 2025

[SOLVED] Monitoring an object changed asynchronously by a Callback function

Scheduled Pinned Locked Moved General and Desktop
callbacksignalslotstatic
11 Posts 2 Posters 5.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 1 Apr 2015, 23:56 last edited by
    #2

    Hi,

    If you need that much performance, you'd better do a benchmark. What is your use case ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    S 1 Reply Last reply 2 Apr 2015, 19:42
    0
    • S SGaist
      1 Apr 2015, 23:56

      Hi,

      If you need that much performance, you'd better do a benchmark. What is your use case ?

      S Offline
      S Offline
      sirop
      wrote on 2 Apr 2015, 19:42 last edited by
      #3

      @SGaist
      I was told today that we'll use milliseconds interval.
      So it is no longer a performance question.

      I just implemented a QTimer for monitoring the callback function changing my vector,
      and it was fast enough.

      To be, or not to be: that is the question:
      Whether ’tis nobler in the mind to suffer
      The slings and arrows of outrageous fortune,
      Or to take arms against a sea of troubles,
      And by opposing end them?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 2 Apr 2015, 21:23 last edited by
        #4

        Why not embed that QVector in a QObject wrapper that will emit a signal whenever the vector is modified ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply 3 Apr 2015, 19:44
        0
        • S SGaist
          2 Apr 2015, 21:23

          Why not embed that QVector in a QObject wrapper that will emit a signal whenever the vector is modified ?

          S Offline
          S Offline
          sirop
          wrote on 3 Apr 2015, 19:44 last edited by sirop 4 Mar 2015, 19:48
          #5

          @SGaist said:

          Why not embed that QVector in a QObject wrapper that will emit a signal whenever the vector is modified ?

          QVector in a QObject wrapper?

          I thought about something like:

          QBuffer buffer(&byteArray);
          

          and then use the above mentioned QBuffer signals.

          To be, or not to be: that is the question:
          Whether ’tis nobler in the mind to suffer
          The slings and arrows of outrageous fortune,
          Or to take arms against a sea of troubles,
          And by opposing end them?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 3 Apr 2015, 20:36 last edited by
            #6

            That's also an alternative yes, you can even go further using a QIODevice derived class and create a device that would your data directly

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sirop
              wrote on 11 Apr 2015, 09:00 last edited by
              #7

              @SGaist

              Yes, I subclassed QBuffer, implemented my own

              qint64 MyBuffer::writeData(const char *data, qint64 len)
              {
                  buffer().clear();
                  buffer().append(data,len);
                  emit bytesWritten(len);
                  return len;
              }
              

              and then:

              QObject::connect(DDEComm::instance()->buf,&QBuffer::bytesWritten,[=](qint64 bytes)
              {
                  printf("bytesWritten: %d, Buffer: %s\n", (int) bytes, DDEComm::instance()->buf->data().data());
              });
              

              It works so far as it should.

              But what was your proposal about embedding QVector in a QObject wrapper?
              Is is something where one has to use http://doc.qt.io/qt-5/properties.html ?

              Anyway I'd mark then this thread as SOLVED.

              To be, or not to be: that is the question:
              Whether ’tis nobler in the mind to suffer
              The slings and arrows of outrageous fortune,
              Or to take arms against a sea of troubles,
              And by opposing end them?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 11 Apr 2015, 23:06 last edited by
                #8

                No you don't have to. The use of properties depends on your software architecture and your class design.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                S 1 Reply Last reply 12 Apr 2015, 01:57
                0
                • S SGaist
                  11 Apr 2015, 23:06

                  No you don't have to. The use of properties depends on your software architecture and your class design.

                  S Offline
                  S Offline
                  sirop
                  wrote on 12 Apr 2015, 01:57 last edited by
                  #9

                  @SGaist
                  How else can I inroduce my own SIGNAL function for any Object?

                  To be, or not to be: that is the question:
                  Whether ’tis nobler in the mind to suffer
                  The slings and arrows of outrageous fortune,
                  Or to take arms against a sea of troubles,
                  And by opposing end them?

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 12 Apr 2015, 22:12 last edited by
                    #10

                    Just declare your signal in the class header and emit it in your code. Take for example QTimer, the timeout signal is not attached to any property and none of them has any signal.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    S 1 Reply Last reply 13 Apr 2015, 01:24
                    0
                    • S SGaist
                      12 Apr 2015, 22:12

                      Just declare your signal in the class header and emit it in your code. Take for example QTimer, the timeout signal is not attached to any property and none of them has any signal.

                      S Offline
                      S Offline
                      sirop
                      wrote on 13 Apr 2015, 01:24 last edited by
                      #11

                      @SGaist

                      Thanks. Now I have a more clear picture about signals.

                      To be, or not to be: that is the question:
                      Whether ’tis nobler in the mind to suffer
                      The slings and arrows of outrageous fortune,
                      Or to take arms against a sea of troubles,
                      And by opposing end them?

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved