Results 1 to 20 of 23

Thread: Freeze using QTimer with interval 0

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    May 2013
    Posts
    321
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: Freeze using QTimer with interval 0

    Qt Code:
    1. #include <QMainWindow>
    2. #include <QDockWidget>
    3. #include <QApplication>
    4. #include <QTimer>
    5.  
    6. class TestWidget : public QWidget
    7. {
    8. public:
    9.  
    10. TestWidget(QWidget* parent = 0) :
    11. QWidget(parent),
    12. m_Initialized(false)
    13. {
    14. m_Timer.setInterval(0);
    15. }
    16.  
    17. QPaintEngine* paintEngine() const
    18. {
    19. return NULL;
    20. }
    21.  
    22. void showEvent(QShowEvent* event)
    23. {
    24. if(m_Initialized == false)
    25. {
    26. connect(&m_Timer, SIGNAL(timeout()), this, SLOT(repaint()));
    27. m_Timer.start();
    28. m_Initialized = true;
    29. }
    30. }
    31.  
    32. private:
    33.  
    34. QTimer m_Timer;
    35. bool m_Initialized;
    36. };
    37.  
    38. class MainWindow : public QMainWindow
    39. {
    40. public:
    41.  
    42. MainWindow(QWidget* parent = 0) :
    43. QMainWindow(parent)
    44. {
    45. QDockWidget* NewDock = new QDockWidget("Test", this);
    46. NewDock->setWidget(new TestWidget(this));
    47. addDockWidget(Qt::BottomDockWidgetArea, NewDock);
    48. }
    49. };
    50.  
    51. int main(int argc, char *argv[])
    52. {
    53. QApplication a(argc, argv);
    54. MainWindow w;
    55. w.show();
    56. return a.exec();
    57. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Alundra; 27th May 2013 at 23:44.

Similar Threads

  1. How to change the Interval Type in QwtPlot?
    By ObiWanKenobe in forum Qwt
    Replies: 4
    Last Post: 16th April 2013, 11:58
  2. Replies: 15
    Last Post: 4th August 2012, 19:11
  3. Replies: 1
    Last Post: 16th May 2012, 11:40
  4. Phonon and the meta interval
    By huilui in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2012, 06:08
  5. QSpinBox interval
    By Jordan in forum Newbie
    Replies: 9
    Last Post: 25th May 2010, 11:07

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.