Results 1 to 4 of 4

Thread: Signal and slot

  1. #1
    Join Date
    Sep 2008
    Location
    New York
    Posts
    90
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Signal and slot

    Please correct me if I am wrong, my understanding about signal and slot is as long as both objects are derived from Q_OBJECT, and signal/slot are define in their class definition, they can be connected anywhere these objects exist.
    For example, I can define all the connections in main.cpp which handles many objects, is that right?

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Signal and slot

    More or less, but its not right to say "objects are derived from Q_OBJECT" as that is a macro definition and not a class - QObject is the class. To use signals/slots you need to have objects which derive from QObject and include the Q_OBJECT macro.

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

    Sheng (17th October 2008)

  4. #3
    Join Date
    Sep 2008
    Location
    New York
    Posts
    90
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Signal and slot

    Quote Originally Posted by JimDaniel View Post
    More or less, but its not right to say "objects are derived from Q_OBJECT" as that is a macro definition and not a class - QObject is the class. To use signals/slots you need to have objects which derive from QObject and include the Q_OBJECT macro.
    Thanks, I find Derived from QWidget might be a better idea since it allows using QMessageBox, while QObject does not.

  5. #4
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Signal and slot

    Sure, you can do that. QWidget itself derives from QObject.

Similar Threads

  1. Replies: 12
    Last Post: 18th September 2008, 16:04
  2. Signal & Slot editor
    By Ishark in forum Qt Tools
    Replies: 4
    Last Post: 28th May 2008, 16:20
  3. Replies: 2
    Last Post: 16th August 2007, 01:20
  4. signal not getting communicated to slot
    By quickNitin in forum Qt Programming
    Replies: 17
    Last Post: 2nd June 2006, 05:56
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 19:52

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.