Results 1 to 3 of 3

Thread: Problem connection Signal and slot

  1. #1
    Join Date
    Jun 2011
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Problem connection Signal and slot

    I have a class KiemTraKetNoi
    Qt Code:
    1. class KiemTraKetNoi : public QObject
    2. {
    3.  
    4. public:
    5. KiemTraKetNoi();
    6. QString KTTruyenDuLieu(QString &str);
    7. bool myCheckConnect();
    8. void TestTime();
    9. public slots:
    10. void kiemTraTimeOut();
    11. private:
    12. QTimer *timer;
    13. QNetworkAccessManager manager;
    14. QNetworkReply *reply;
    15. };
    To copy to clipboard, switch view to plain text mode 

    in KiemTraKetNoi:
    Qt Code:
    1. QString KiemTraKetNoi::KTTruyenDuLieu(QString &str)
    2. {
    3. //QNetworkAccessManager manager;
    4. reply=manager.get(QNetworkRequest(QUrl(str)));
    5. QEventLoop evLoop;
    6. QObject::connect(reply,SIGNAL(readyRead()),&evLoop,SLOT(quit()));
    7. QObject::connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),&evLoop,SLOT(quit()));
    8.  
    9. QObject::connect(timer,SIGNAL(timeout()),this,SLOT(kiemTraTimeOut()));
    10.  
    11. if(!timer->isActive())
    12. timer->start();
    13.  
    14. evLoop.exec();
    15. ....
    16. }
    To copy to clipboard, switch view to plain text mode 
    and timer = new QTimer(this);
    Qt Code:
    1. void KiemTraKetNoi::kiemTraTimeOut()
    2. {
    3. timer->stop();
    4. reply->abort();
    5. }
    To copy to clipboard, switch view to plain text mode 

    When my app running in main.cpp , it show message:
    Object::connect: No such slot QObject::kiemTraTimeOut() in ..\TuDienVanHoa\kiemtraketnoi.cpp:23

    I don't understand it. Help me!

  2. #2
    Join Date
    Feb 2011
    Location
    Romania
    Posts
    53
    Thanks
    1
    Thanked 11 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem connection Signal and slot

    You should write Q_OBJECT macro in "KiemTraKetNoi" class.

  3. #3
    Join Date
    Jun 2011
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Problem connection Signal and slot

    Thank cincirin!
    I resolved my error.

Similar Threads

  1. Signal/Slot connection problem
    By nightroad in forum Newbie
    Replies: 2
    Last Post: 6th April 2011, 09:30
  2. Signal/Slot connection failing
    By Polnareff in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2010, 20:41
  3. Signal and Slot connection not working !!
    By prakash437 in forum Qt Programming
    Replies: 3
    Last Post: 17th May 2010, 10:16
  4. Signal and slot connection graph
    By fahlen in forum General Discussion
    Replies: 4
    Last Post: 27th November 2007, 13:47
  5. signal slot connection
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 4th July 2006, 13:31

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.