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 & slot

signal & slot

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 961 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.
  • R Offline
    R Offline
    Ripon Azad
    wrote on last edited by
    #1

    Is it possible to connect signal and slot of two different classes from a 3rd class?

    E 1 Reply Last reply
    0
    • R Ripon Azad

      Is it possible to connect signal and slot of two different classes from a 3rd class?

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @Ripon-Azad Yes, one of the important features of Qt's signal/slot mechanism is that the sender and receiver don't have to know anything about each other or about the connection between them. You just have to use one of the static QObject::connect functions if you don't do it in the receiver object.

      R 1 Reply Last reply
      1
      • E Eeli K

        @Ripon-Azad Yes, one of the important features of Qt's signal/slot mechanism is that the sender and receiver don't have to know anything about each other or about the connection between them. You just have to use one of the static QObject::connect functions if you don't do it in the receiver object.

        R Offline
        R Offline
        Ripon Azad
        wrote on last edited by
        #3

        @Eeli-K thanks for replaying. but I am having a problem.. for example:
        classA
        {
        signal a;
        }

        and
        classB
        {
        slot b;
        }
        now I am in
        classC
        {
        how can I connect signal a and slot b here? I mean QObject::connect(..............) about this line.
        }

        E 1 Reply Last reply
        0
        • R Ripon Azad

          @Eeli-K thanks for replaying. but I am having a problem.. for example:
          classA
          {
          signal a;
          }

          and
          classB
          {
          slot b;
          }
          now I am in
          classC
          {
          how can I connect signal a and slot b here? I mean QObject::connect(..............) about this line.
          }

          E Offline
          E Offline
          Eeli K
          wrote on last edited by
          #4

          @Ripon-Azad You have to able to reach the object of type classA and the object of type classB in a method of classC. They can be given as arguments to the method or be members of classC, or whatever makes them available. Then just use one of the static QObject::connect functions and give the sender object, signal, receiver object and and slot as arguments. For details and examples read http://doc.qt.io/qt-5/signalsandslots.html, it a must-read anyways because it's so central in using Qt. Try something first and ask specific questions if need arises.

          R 1 Reply Last reply
          0
          • E Eeli K

            @Ripon-Azad You have to able to reach the object of type classA and the object of type classB in a method of classC. They can be given as arguments to the method or be members of classC, or whatever makes them available. Then just use one of the static QObject::connect functions and give the sender object, signal, receiver object and and slot as arguments. For details and examples read http://doc.qt.io/qt-5/signalsandslots.html, it a must-read anyways because it's so central in using Qt. Try something first and ask specific questions if need arises.

            R Offline
            R Offline
            Ripon Azad
            wrote on last edited by
            #5

            @Eeli-K thank you so much. Although I read it already but I will look it again.

            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