Results 1 to 4 of 4

Thread: Slot inheritance

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Slot inheritance

    just copy pasted your example and it works for me.

    tst.h
    Qt Code:
    1. class abstract_therapy : public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. void testFunction();
    6. public slots:
    7. void testSlot(){ qDebug() << "in slot"; }
    8. private:
    9. QTimer* m1;
    10. };
    11.  
    12. class B : public abstract_therapy
    13. {
    14. Q_OBJECT
    15. public:
    16. void abc(){}
    17. };
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include <QtCore>
    2.  
    3. #include "tst.h"
    4.  
    5. void abstract_therapy::testFunction()
    6. {
    7. m1 = new QTimer(this);
    8. m1->connect(m1, SIGNAL(timeout()), this, SLOT(testSlot()));
    9. m1->setInterval(500);
    10. m1->start();
    11. }
    12.  
    13. int main(int argc, char *argv[])
    14. {
    15. QCoreApplication a(argc, argv);
    16.  
    17. abstract_therapy* _therapy;
    18. _therapy = new B;
    19.  
    20. _therapy->testFunction();
    21.  
    22. return a.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 



    and here is the output


    Starting /home/nish/Desktop/progs/tst/tst-build-desktop/tst...
    in slot
    in slot
    in slot
    in slot
    in slot
    in slot
    in slot
    in slot
    in slot
    in slot
    in slot
    in slot
    in slot
    in slot

  2. The following user says thank you to nish for this useful post:

    kartun (28th February 2011)

Similar Threads

  1. signal/slot problems with inheritance
    By Slewman in forum Qt Programming
    Replies: 11
    Last Post: 7th December 2010, 15:19
  2. Replies: 8
    Last Post: 13th July 2010, 14:08
  3. inheritance
    By mickey in forum General Programming
    Replies: 11
    Last Post: 28th September 2007, 21:54
  4. How much inheritance do you use?
    By Michiel in forum General Programming
    Replies: 8
    Last Post: 1st August 2006, 22:29
  5. QSA and inheritance
    By jwintz in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2006, 14:05

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