Do you have an event loop running?
Do you have an event loop running?
Header File:
Qt Code:
#ifndef __INWAITSPLASH_H__ #define __INWAITSPLASH_H__ #include "ui_INWaitSplash.h" #define ROWSIZE 4 #define COLUMNSIZE 4 #define TAILLENGTH 4 { Q_OBJECT public: void Init(); void Start(); void Stop(); protected: void InitTable(); private slots: // Table Pattern Algorithms void FillTable_SnakePattern(); //void FillTable_RandomPattern(); //void FillTable_BoxPattern(); private: Ui::SplashForm ui; QTimer* m_timerMain; int m_aiCellTable[COLUMNSIZE][ROWSIZE]; }; #endifTo copy to clipboard, switch view to plain text mode
As for an event loop... I would have to say no because I am not sure what an event loop is. It is strange because if I turn the timers setInterval(100) to start(100) it will trigger... but after I run my Start() method from a function in my MainWindow it stops... and obviously stops on my Stop() method. So I know the connection is setup. I must be missing something fundamental.
What do you do after you call Start()? If you don't have an event loop running (either by calling QDialog::exec() or QApplication::exec() or reapeating QApplication:rocessEvents() calls) timers won't work.
Interesting...
This is what I am doing.
I have a class that contains a pointer to my MainWindow and my Splash Screen Widget.
There I create a "singleton" instance of it that my class that can be used in my MainWindow's class. So inside a method of my MainWindow I am calling something like this:
Qt Code:
void CINMainWindow::Search() { INMyApp()->INWaitSplash()->Start(); CINTimer::Sleep(1000); // Something meaningful would be done here INMyApp()->INWaitSplash()->Stop(); }To copy to clipboard, switch view to plain text mode
So I am calling Start() and Stop() to my splash screen class from any where I want.
It doesn't have any chance to work then. If you want to use timers, you have to call QApplication::exec() before or right after Start() and do the rest as small steps triggered by another timer with timeout set to 0, more or less like so:
Qt Code:
void MyClass::init1(){ //... } void MyClass::init2(){ //... } // ... return app.exec();To copy to clipboard, switch view to plain text mode
Timers can only timeout() when the control is in the event loop, so having a single long operation won't allow them to be triggered as well. You either have to use QApplication:rocessEvents() or use 0-timeout timers like on the example above.
Bookmarks