Results 1 to 2 of 2

Thread: Is there a signal "broadcast" capability in Qt?

  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,836
    Thanks
    269
    Thanked 785 Times in 775 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Is there a signal "broadcast" capability in Qt?

    I have a situation where I need to post a certain dialog from multiple places in my application, some at the top level (a MainWindow menu command), some buried deep in the hierarchy of GUI layers or in dialogs. For re-usability and maintenance purposes, I want to avoid having some low-level dialog need to know about a MainWindow instance in order to make a connection, as well as avoiding having to relay a signal up to the top level through a series of signals implemented in parents of the low-level class.

    I would also like to avoid having all the low-level classes know that it's a dialog that needs to be posted. I just want them to be able to emit a signal that says something generic, like "doThisThing" and somewhere above it, some object sees that signal and says, I don't know who sent this, but I'll "doTheThing".

    Normal signal-slot connections are point-to-point, that is, a connection is between a specific sender and receiver (which could be a lambda).

    Is there any mechanism in Qt for signal broadcasting? That is, where a QObject instance could emit a signal, and another QObject instance could connect a slot to that signal, but where the instance sending the signal is not known at the time the connection is made? A connection of the form:

    Qt Code:
    1. connect( &someSignal, this, &MyClass::mySlot );
    To copy to clipboard, switch view to plain text mode 

    Or am I confused and this is just another case of the famous "ComeFrom" statement in BASIC?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    523
    Thanked 81 Times in 76 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is there a signal "broadcast" capability in Qt?

    I would say this is a task for a CustomEvent then.

  3. The following user says thank you to ChristianEhrlicher for this useful post:

    d_stranz (28th January 2021)

Similar Threads

  1. Replies: 1
    Last Post: 20th November 2015, 11:02
  2. QSqlError("", "Parameter count mismatch", "")
    By Alberto7 in forum Newbie
    Replies: 2
    Last Post: 9th October 2015, 23:09
  3. Replies: 3
    Last Post: 16th March 2015, 08:31
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 20:05
  5. Signal defined in "a.h" can not emit in "b.cpp"
    By Shawn in forum Qt Programming
    Replies: 9
    Last Post: 21st May 2007, 17:55

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.