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. Problem with signal system
Forum Updated to NodeBB v4.3 + New Features

Problem with signal system

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 2.4k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    Remi73
    wrote on last edited by
    #1

    Hello,

    I will try to explain my problem (about order of receive signal):

    I've two different object instanciate (O1, O2) and two qml files (Q1, Q2).
    In one qml file Q1, I made a connection between signal from O1 and slot from O2.
    In O1 I have a Q_PROPERTY (read write notify).
    In the setter of the Q_PROPERTY I have an emit of the previous signal.
    During the execution I regulary emit the signal (out of the setter), and when I press a button in Q2, it call the setter of the O1's Q_PROPERTY and so emit the signal and stop the other emission.

    The problem is that the slot in O2 receive signals in a bad order : signal send in the setter is immediatly receive, before some signal which are emit before.

    Is it clear :/ ?

    Edit: Same if I use a Q_INVOKABLE function instead of setter.

    Thank

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Not really clear, can you show a code sample ?

      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
      • R Offline
        R Offline
        Remi73
        wrote on last edited by
        #3

        Object1:
        @Q_PROPERTY property READ WRITE NOTIFY
        while(update) {
        emit signalToObject2();
        }
        propertySet() {
        update = false;
        emit signalToObject2();
        }@

        Object2:
        @slotReceiveSignalFromObject1() {
        ...
        }@

        QML1:
        @object1.signalToObject2.connect(Object2.slotReceiveSignalFromObject1);@

        QML2:
        @button {
        onClicked: object1.property = ...;
        }@

        Result is when I click, I receive immediatly the signal send in propertySet() and after I receive signal which were pending (send in while, before the set). Like if in the set, signals are priority.

        You see ? Thank to try to understand me ^^'

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Sending signals from a while loop like that is bad design, why are you doing it ?

          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
          • R Offline
            R Offline
            Remi73
            wrote on last edited by
            #5

            Sorry it's just to describe the problem.. I'm working on leap motion, the while in my example correspond to a listener connected to the leap motion frames. Like:

            @void object1::onFrameReceive()
            {
            if (drawHand)
            emit signalToObject2()
            }@

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Got any thread running ?

              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
              • jeremy_kJ Offline
                jeremy_kJ Offline
                jeremy_k
                wrote on last edited by
                #7

                Can we get a working example? The pseudocode posted leaves large gaps that could contain all sorts of hypothetical problems. We can spend all day guessing about situations that don't apply to the real problem.

                Asking a question about code? http://eel.is/iso-c++/testcase/

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Remi73
                  wrote on last edited by
                  #8

                  I can't give you a working example...

                  I feel that sending a signal in a classic function call is not the same as sending a signal in a setter call throught the Q_PROPERTY system like if there is a priority or an immediate call to the function (bypassing the queue).
                  Do you thing it's possible ?

                  I'm starting with Qt sorry..

                  1 Reply Last reply
                  0
                  • jeremy_kJ Offline
                    jeremy_kJ Offline
                    jeremy_k
                    wrote on last edited by
                    #9

                    Lacking a working example, or valid C++ and QML, my suggestion is to read the documentation on signals and slots, and the property system.

                    Depending on the connection, delivery of a signal to a slot may occur via a direct function call, or the event loop of the receiver.

                    Asking a question about code? http://eel.is/iso-c++/testcase/

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Remi73
                      wrote on last edited by
                      #10

                      The connection is made under QML, so I can't choose connection mode. I think this is automatic connection ? Maybe one signal use queued connection and the other use direct ?

                      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