Results 1 to 1 of 1

Thread: Signal do not work in derived class

  1. #1
    Join Date
    Mar 2011
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signal do not work in derived class

    I have such code:
    Qt Code:
    1. class A : public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. explicit A(QObject *parent = 0) : QObject(parent)
    6. {
    7. connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
    8. }
    9.  
    10. void sendRequest()
    11. {
    12. // ...
    13. http.request(...);
    14. }
    15.  
    16. public slots:
    17. void httpDone(bool)
    18. {
    19. qDebug() << "recieved!";
    20. }
    21.  
    22. protected:
    23. QHttp http;
    24.  
    25. };
    26.  
    27. class B : public A
    28. {
    29. //...
    30. void getSomething()
    31. {
    32. sendRequest();
    33. }
    34. };
    35.  
    36. class C : public A
    37. {
    38. //...
    39. void getSomething()
    40. {
    41. sendRequest();
    42. }
    43. };
    44.  
    45. // and now do some stuff
    46. B b;
    47. C c;
    48. b.getSomething();
    49. c.getSomething();
    To copy to clipboard, switch view to plain text mode 

    And there is only one "recieved!" message in console from b. Why?


    Added after 14 minutes:


    From qDebug() << connect(..) output I see that SIGNAL connects to SLOT (return value is true).


    Added after 17 minutes:


    Sorry.., it`s my fault. And that is why I have to go to sleep right now.
    Last edited by nickla; 19th March 2011 at 22:25.

Similar Threads

  1. Replies: 1
    Last Post: 14th August 2009, 21:17
  2. Can not cast into the derived class from QScrollBar
    By learning_qt in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2008, 10:23
  3. no frame on Qlabel derived class
    By tupu_83 in forum Qt Programming
    Replies: 2
    Last Post: 19th November 2008, 16:01
  4. rtti() of derived class
    By quickNitin in forum Newbie
    Replies: 4
    Last Post: 8th October 2006, 14:20
  5. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 07:36

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.