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. Qt Eventing without know receiver (decoupling of objects) possible?
QtWS25 Last Chance

Qt Eventing without know receiver (decoupling of objects) possible?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 4.2k 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.
  • B Offline
    B Offline
    bkamps
    wrote on last edited by
    #1

    Hi,

    I want to be able to send events to objects, so for so good because I can use Qt eventing (postEvent) :-) !

    But I also want that the sending and receiving objects are decoupled! I don't want the sender object to have any knowledge of the receiving object. And as far as I can see you need to enter a receiver QObject * to postEvent method :-(

    Is it possible with Qt eventing to send events and whoever listens receives this event and can handle/ignore it?

    Thanks a lot!

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      Why not just use a signal?

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bkamps
        wrote on last edited by
        #3

        Because signal/slots are synchronous, right? And I still need to have both objects to "connect" each other.

        I would like a mechanism where you can thrown something in the event queue and all objects listening to that queue can use or ignore the event. Is this possible with Qt Eventing?

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          If you specify Qt::QueuedConnection in your connect statement then the signals make use of the receiver object's event queue (must have event loop running though) rather than being synchronous direct function calls.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            no, it is not.

            Events are always send to a receiver. You always send to a target. send to unknown objects is signal/slot, but then you need the connect statement, that's correct.

            What you could theoretically do is send the event to the QApplication and everybody can install an event filter there and handle them. But that's not a nice design.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bkamps
              wrote on last edited by
              #6

              Ok, too bad. I guess I'll have to find another way to do this.

              Thnx!

              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