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. Connect , SendMessage, Emit - When should I take what?

Connect , SendMessage, Emit - When should I take what?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 110 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
    RobertSommer
    wrote last edited by
    #1

    Hello,
    Can someone please show me how to send a SendMessage?
    YXYXYAshampoo_Snap_Samstag, 3. Mai 2025_17h21m10s.png

    • From Laser to Controller
    • From Ink to Controller

    And when should I take what?
    Connect with signal ans slots or wir SendMessage, emit?

    Pl45m4P 1 Reply Last reply
    0
    • Axel SpoerlA Online
      Axel SpoerlA Online
      Axel Spoerl
      Moderators
      wrote last edited by
      #4

      Adding to @Pl45m4
      In order to use signal/slot connections, sender and receiver need to inherit from QObject.

      @RobertSommer I am not exactly sure, what is meant by sendMessage. There is no such thing in Qt, except for DBus and network connections which both make no sense in this context.

      If you mean sending events, that's another thing. Certainly also a solution for your use case, but a little more complex to handle than just using signals/slots.

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CassD
        wrote last edited by CassD
        #2

        To send a message from controller to it's inner components, you do this classically via calling the method you want to execute on the component, no need for signals or slots in that case.

        However for the internal component to notify of something to the controller, then you connect the component's signal to the controller's slot.

        1 Reply Last reply
        0
        • R RobertSommer

          Hello,
          Can someone please show me how to send a SendMessage?
          YXYXYAshampoo_Snap_Samstag, 3. Mai 2025_17h21m10s.png

          • From Laser to Controller
          • From Ink to Controller

          And when should I take what?
          Connect with signal ans slots or wir SendMessage, emit?

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote last edited by Pl45m4
          #3

          @RobertSommer

          The connections mentioned by @CassD should be established in the controller class where both child objects are known.
          You connect Ink to Controller and Laser the same way. I assume these are printers (or printer software)?! Ink Jet + Laser printers, right?!

          BTW emit does nothing. It is defined to (whitespace). It's just there for us humans to distinguish between signal "calls" and functions calls. You don't need to write emit ever. It would work the same without :-)

          Before asking more general questions like that (nothing wrong with that), you should read

          • https://doc.qt.io/qt-6/signalsandslots.html

          in case you haven't already.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          R 1 Reply Last reply
          2
          • Axel SpoerlA Online
            Axel SpoerlA Online
            Axel Spoerl
            Moderators
            wrote last edited by
            #4

            Adding to @Pl45m4
            In order to use signal/slot connections, sender and receiver need to inherit from QObject.

            @RobertSommer I am not exactly sure, what is meant by sendMessage. There is no such thing in Qt, except for DBus and network connections which both make no sense in this context.

            If you mean sending events, that's another thing. Certainly also a solution for your use case, but a little more complex to handle than just using signals/slots.

            Software Engineer
            The Qt Company, Oslo

            1 Reply Last reply
            0
            • R RobertSommer has marked this topic as solved
            • Pl45m4P Pl45m4

              @RobertSommer

              The connections mentioned by @CassD should be established in the controller class where both child objects are known.
              You connect Ink to Controller and Laser the same way. I assume these are printers (or printer software)?! Ink Jet + Laser printers, right?!

              BTW emit does nothing. It is defined to (whitespace). It's just there for us humans to distinguish between signal "calls" and functions calls. You don't need to write emit ever. It would work the same without :-)

              Before asking more general questions like that (nothing wrong with that), you should read

              • https://doc.qt.io/qt-6/signalsandslots.html

              in case you haven't already.

              R Offline
              R Offline
              RobertSommer
              wrote last edited by
              #5

              @Pl45m4 said in Connect , SendMessage, Emit - When should I take what?:

              @RobertSommer

              You connect Ink to Controller and Laser the same way. I assume these are printers (or printer software)?! Ink Jet + Laser printers, right?!

              That is correct.

              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