Sorry but can I use threadsleeper::msleep(m_sleep); to sleep main thread ?
			
		
 
	 
 You can use it to sleep any thread. More precisely, it sleeps the thread that calls this method. And as the main thread is a thread as any other thread, why shouldn't it be sent to sleep by calling this method? If you don't believe, just try this little code snippet:
	
	- #include <QCoreApplication> 
- #include <QThread> 
- #include <iostream> 
- #include <QTime> 
-   
-     { 
-     private: 
-         ThreadSleeper(){}; 
-         virtual ~ThreadSleeper(){}; 
-   
-     public: 
-     }; 
-   
-   
- int main(int , char *[]) 
- { 
-     std::cout << "sleeping for 5s" << std::endl; 
-     t.start(); 
-     ThreadSleeper::msleep(5000); 
-     std::cout << "slept for " << t.elapsed() << "ms" << std::endl; 
- } 
        #include <QCoreApplication>
#include <QThread>
#include <iostream>
#include <QTime>
class ThreadSleeper:public QThread
    {
    private:
        ThreadSleeper(){};
        virtual ~ThreadSleeper(){};
    public:
        using QThread::msleep;
    };
int main(int , char *[])
{
    std::cout << "sleeping for 5s" << std::endl;
    QTime t;
    t.start();
    ThreadSleeper::msleep(5000);
    std::cout << "slept for " << t.elapsed() << "ms" << std::endl;
}
To copy to clipboard, switch view to plain text mode 
  Best regards
ars
@Prasad_N: I didn't see your previous reply before posting the above.
				
			
Bookmarks