Results 1 to 3 of 3

Thread: SigSlot conn from base classs to subclass

  1. #1
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default SigSlot conn from base classs to subclass

    Hi,

    I'm subclassing QHttp to a class called HttpSyncr.

    I have the following slot declarations in HttpSyncr.h:
    Qt Code:
    1. public slots:
    2. void ReceiveResponseHeader(const QHttpResponseHeader& header);
    3. void HttpRequestStarted(int id);
    4. void HttpRequestFinished(int id, bool error);
    To copy to clipboard, switch view to plain text mode 

    This is how I'm connecting:
    Qt Code:
    1. HttpSyncr::HttpSyncr(QObject *parent)
    2. : QHttp(parent)
    3. {
    4. bool res = connect(this, SIGNAL(responseHeaderReceived(const QHttpResponseHeader&)), this, SLOT(ReceiveResponseHeader(const QHttpResponseHeader&)));
    5. res = connect(this, SIGNAL(requestStarted(int)), this, SLOT(HttpRequestStarted(int)));
    6. res = connect(this, SIGNAL(requestFinished(int, bool)), this, SLOT(HttpRequestFinished(int, bool)));
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

    I figured that simply specifying 'this' as both source and target would be okay, but the slot is getting defined incorrectly. My debug output from the connect() function is:
    Object::connect: No such slot QHttp::ReceiveResponseHeader(QHttpResponseHeader)
    Object::connect: No such slot QHttp::HttpRequestStarted(int)
    Object::connect: No such slot QHttp::HttpRequestFinished(int,bool)
    Is there a way to force MOC to know that the slot is actually in HttpSyncr and not the base class?


    Steve

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: SigSlot conn from base classs to subclass

    Is there a way to force MOC to know that the slot is actually in HttpSyncr and not the base class?
    yes, use Q_OBJECT macro in your class.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

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

    stevey (5th September 2009)

  4. #3
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SigSlot conn from base classs to subclass

    Well far out and golly jee wizz!
    Thanks for that, I forgot about the illusive macro of doom.

    It didn't occur to me that I'd need it in a subclass, but that's only header files of course. The subclass still needs to registered, all makes sense now.

    Thanks again.

    Steve

Similar Threads

  1. Signal in base class Slot in Subclass
    By csvivek in forum Newbie
    Replies: 7
    Last Post: 30th March 2008, 16: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.