Results 1 to 10 of 10

Thread: using assert, assertion failed, QTimerEvent keeps getting called! (qt3.3.8, vs2005)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Feb 2008
    Posts
    491
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    12
    Thanked 142 Times in 135 Posts

    Default Re: using assert, assertion failed, QTimerEvent keeps getting called! (qt3.3.8, vs200

    QT_FATAL_ASSERT works with Q_ASSERT.

    The following works on my box:
    Qt Code:
    1. #define QT_FATAL_ASSERT
    2. #include <qapplication.h>
    3. #include <qobject.h>
    4.  
    5. class Object : public QObject
    6. {
    7. Q_OBJECT
    8. public:
    9. Object(){
    10. startTimer(1000);
    11. }
    12.  
    13. void timerEvent(QTimerEvent *event){
    14. Q_ASSERT(0);
    15. }
    16. };
    17.  
    18. int main(int argc, char *argv[]){
    19.  
    20. QApplication app(argc, argv);
    21. Object obj;
    22. app.exec();
    23. }
    24.  
    25. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    And so does your app with modifications:
    Qt Code:
    1. #include <cassert>
    2. #include <qobject.h>
    3. #include <qapplication.h>
    4. #include <iostream>
    5.  
    6. class MyObject : public QObject
    7. {
    8. public:
    9. MyObject() { startTimer(100); }
    10.  
    11. virtual void timerEvent(QTimerEvent* e)
    12. {
    13. std::cout<<"beforeAssert" << std::endl;
    14. assert(0);
    15. std::cout<<"afterAssert";
    16. }
    17. };
    18.  
    19.  
    20. int main(int argc, char** argv)
    21. {
    22. QApplication app(argc, argv);
    23.  
    24. MyObject object;
    25.  
    26. return (app.exec());
    27. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by norobro; 22nd February 2011 at 16:45. Reason: had Qt4 includes

Similar Threads

  1. Replies: 2
    Last Post: 17th December 2010, 08:26
  2. Replies: 7
    Last Post: 26th July 2008, 13:24
  3. "Debug Assertion failed" in debug mode
    By hed in forum Qt Programming
    Replies: 10
    Last Post: 4th February 2008, 12:10
  4. Debug Assertion Failed
    By ^NyAw^ in forum General Programming
    Replies: 5
    Last Post: 28th December 2007, 11:48
  5. ASSERT(Failed assertion in Qt == Qt bug)
    By 0xBulbizarre in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2006, 19:06

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.