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. Signal and Slot
Forum Updated to NodeBB v4.3 + New Features

Signal and Slot

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 880 Views 2 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.
  • Chris KawaC Offline
    Chris KawaC Offline
    Chris Kawa
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi, see Signals & Slots in the documentation for detailed explanation.

    1 Reply Last reply
    1
    • E Offline
      E Offline
      Emre MUTLU
      wrote on last edited by Emre MUTLU
      #3
      QObject::connect(SignalSender,SIGNAL(yoursignal),SignalReceiver,SLOT(yourslot));
      

      ex:

      MainWindow w;
      myClass myObj;
      QObject::connect(&w,SIGNAL(someSignal),&myObj,SLOT(someSlotinMyClass);
      

      if you use pointer then don't necessary '&'

      jsulmJ 1 Reply Last reply
      0
      • E Emre MUTLU
        QObject::connect(SignalSender,SIGNAL(yoursignal),SignalReceiver,SLOT(yourslot));
        

        ex:

        MainWindow w;
        myClass myObj;
        QObject::connect(&w,SIGNAL(someSignal),&myObj,SLOT(someSlotinMyClass);
        

        if you use pointer then don't necessary '&'

        jsulmJ Online
        jsulmJ Online
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @Emre-MUTLU It is better to use newer Qt5 connect syntax as it gives you compile time errors if you do something wrong instead of runtime errors.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Emre MUTLU
          wrote on last edited by
          #5
          connect(sender, &sender::Signal, this, &MyObj::someSLOT);
          

          like this right ?

          jsulmJ 1 Reply Last reply
          0
          • E Emre MUTLU
            connect(sender, &sender::Signal, this, &MyObj::someSLOT);
            

            like this right ?

            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @Emre-MUTLU said in Signal and Slot:

            connect(sender, &sender::Signal, this, &MyObj::someSLOT);

            Almost:

            connect(sender, &SenderClass::Signal, this, &MyObj::someSLOT);
            

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • E Offline
              E Offline
              Emre MUTLU
              wrote on last edited by
              #7
              This post is deleted!
              1 Reply Last reply
              0
              • K Offline
                K Offline
                kamejoko
                wrote on last edited by kamejoko
                #8

                sorry, i don't ask the syntax of signal and slot. I want to understand meta-object compiler. Signal and slot are macros and they are connected by meta-object, right?

                JKSHJ jsulmJ 2 Replies Last reply
                0
                • K kamejoko

                  sorry, i don't ask the syntax of signal and slot. I want to understand meta-object compiler. Signal and slot are macros and they are connected by meta-object, right?

                  JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #9

                  @kamejoko said in Signal and Slot:

                  I want to understand meta-object compiler. Signal and slot are macros and they are connected by meta-object, right?

                  You can start here: https://woboq.com/blog/how-qt-signals-slots-work.html (at the end of this article, there is a link to Part 2)

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  K 1 Reply Last reply
                  2
                  • K kamejoko

                    sorry, i don't ask the syntax of signal and slot. I want to understand meta-object compiler. Signal and slot are macros and they are connected by meta-object, right?

                    jsulmJ Online
                    jsulmJ Online
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @kamejoko said in Signal and Slot:

                    Signal and slot are macros

                    No, they are methods. Slot is written by programmer. Signal is generated for you by moc and you can see how it is implemented by looking into generated header file. QObject::connect just memorises that the slot needs to be called when the signal is called.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    K 1 Reply Last reply
                    1
                    • JKSHJ JKSH

                      @kamejoko said in Signal and Slot:

                      I want to understand meta-object compiler. Signal and slot are macros and they are connected by meta-object, right?

                      You can start here: https://woboq.com/blog/how-qt-signals-slots-work.html (at the end of this article, there is a link to Part 2)

                      K Offline
                      K Offline
                      kamejoko
                      wrote on last edited by
                      #11

                      @JKSH thank you about that!

                      1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @kamejoko said in Signal and Slot:

                        Signal and slot are macros

                        No, they are methods. Slot is written by programmer. Signal is generated for you by moc and you can see how it is implemented by looking into generated header file. QObject::connect just memorises that the slot needs to be called when the signal is called.

                        K Offline
                        K Offline
                        kamejoko
                        wrote on last edited by
                        #12

                        @jsulm thanks. that's exactly is which i want to know. Could you tell me how many type of signal and slots mechanism? I read at doc.qi.io and i see there are two signal and slots mechanism. One is "Signals and slots with default argument". Two is "Advance signals and slots Usage". I don't know whether i'm true

                        jsulmJ 1 Reply Last reply
                        0
                        • K kamejoko

                          @jsulm thanks. that's exactly is which i want to know. Could you tell me how many type of signal and slots mechanism? I read at doc.qi.io and i see there are two signal and slots mechanism. One is "Signals and slots with default argument". Two is "Advance signals and slots Usage". I don't know whether i'm true

                          jsulmJ Online
                          jsulmJ Online
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by jsulm
                          #13

                          @kamejoko said in Signal and Slot:

                          Could you tell me how many type of signal and slots mechanism?

                          I'm not sure what you're asking.
                          There is only one type of signals/slots, but two different ways to connect them:

                          • The old connect syntax using SIGNAL and SLOT macros
                          • The newer and better connect syntax using function pointers

                          Signals and slots can have 0..n parameters, like any other function/method.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          K 1 Reply Last reply
                          3
                          • jsulmJ jsulm

                            @kamejoko said in Signal and Slot:

                            Could you tell me how many type of signal and slots mechanism?

                            I'm not sure what you're asking.
                            There is only one type of signals/slots, but two different ways to connect them:

                            • The old connect syntax using SIGNAL and SLOT macros
                            • The newer and better connect syntax using function pointers

                            Signals and slots can have 0..n parameters, like any other function/method.

                            K Offline
                            K Offline
                            kamejoko
                            wrote on last edited by
                            #14

                            @jsulm ok. thank you very much. My question is solved!

                            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