Results 1 to 3 of 3

Thread: Relaying signals--Is this typical, or is it a bad design?

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Relaying signals--Is this typical, or is it a bad design?

    I frequently have Q_Object classes that contain other Q_Objects as private members. Signals that occur in these contained QObjects need to be connected by the owner of the class that contains them. Consequently I end up creating slots in classes that own Q_Objects that do nothing other than emit a duplicate signal of what caused them to be executed.

    For example, say class (QObject A) contains a QObject B and a QObject C. Furthermore, QObject B contains a QObject D.

    A signal that occurs in QObject D needs to be connected to a slot in QObject C. To do this, I create a slot in QObject B. It's connected in B's code to a slot in B that emits a signal This B signal is then be connected to QObject D in a method in QObject A.

    I could instead declare the the contained Objects (and/or methods) B and D public so the owning classes can do the connection directly, but I'm wondering if this is a typical situation? Does this indicate a bad design? or am I "picking at nits"?

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Relaying signals--Is this typical, or is it a bad design?

    You can connect a signal to another signal.

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

    davethomaspilot (24th December 2014)

  4. #3
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Relaying signals--Is this typical, or is it a bad design?

    Never saw that and that's what I needed!

    Thanks

Similar Threads

  1. Design: Signals => Pass by Reference
    By tescrin in forum Qt Programming
    Replies: 19
    Last Post: 7th December 2012, 21:40
  2. Typical Design Issue
    By sajis997 in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2012, 16:14
  3. Non-typical and Non-linear wizard
    By kornicameister in forum Qt Programming
    Replies: 4
    Last Post: 30th December 2010, 15:26
  4. Relaying a keyPressEvent from one Widget to another
    By bbdaffy in forum Qt Programming
    Replies: 4
    Last Post: 6th October 2010, 10:02
  5. relaying signals
    By Cruz in forum Qt Programming
    Replies: 7
    Last Post: 6th April 2010, 17:59

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
  •  
Qt is a trademark of The Qt Company.