Difference between revisions of "Qt/Widgets/Thread"

From ProgrammingExamples
< Qt
Jump to: navigation, search
(Created page with '==Thread.cxx== <source lang="cpp"> #include <QThread> class MyThread : public QThread { public: virtual void run(); }; void MyThread::run() { for( int count = 0; count …')
 
(hqwmEz <a href="http://ovjmkrdtktsy.com/">ovjmkrdtktsy</a>, [url=http://xtqvcbpzmtsu.com/]xtqvcbpzmtsu[/url], [link=http://dyoshtvvwjbt.com/]dyoshtvvwjbt[/link], http://bxdvjbgwgzll.com/)
Line 1: Line 1:
−
==Thread.cxx==
+
hqwmEz  <a href="http://ovjmkrdtktsy.com/">ovjmkrdtktsy</a>, [url=http://xtqvcbpzmtsu.com/]xtqvcbpzmtsu[/url], [link=http://dyoshtvvwjbt.com/]dyoshtvvwjbt[/link], http://bxdvjbgwgzll.com/
−
<source lang="cpp">
+
−
#include <QThread>
+
−
 
+
−
class MyThread : public QThread
+
−
{
+
−
 
+
−
public:
+
−
 
+
−
    virtual void run();
+
−
};
+
−
 
+
−
void MyThread::run()
+
−
{
+
−
  for( int count = 0; count < 20; count++ )
+
−
  {
+
−
    sleep( 1 );
+
−
    qDebug( "Ping!" );
+
−
  }
+
−
}
+
−
 
+
−
int main()
+
−
{
+
−
  MyThread a;
+
−
  MyThread b;
+
−
  a.start();
+
−
  b.start();
+
−
  a.wait();
+
−
  b.wait();
+
−
 
+
−
  return 0;
+
−
}
+
−
</source>
+
  
 
==CMakeLists.txt==
 
==CMakeLists.txt==

Revision as of 09:50, 2 March 2011

hqwmEz <a href="http://ovjmkrdtktsy.com/">ovjmkrdtktsy</a>, [url=http://xtqvcbpzmtsu.com/]xtqvcbpzmtsu[/url], [link=http://dyoshtvvwjbt.com/]dyoshtvvwjbt[/link], http://bxdvjbgwgzll.com/

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
 
PROJECT(Thread)
 
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})
 
include_directories(${include_directories} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
 
ADD_EXECUTABLE(Thread Thread.cpp)# ${MOCSrcs} ${UISrcs})
TARGET_LINK_LIBRARIES(Thread ${QT_LIBRARIES})