Difference between revisions of "Qt/Widgets/Thread"

From ProgrammingExamples
< Qt
Jump to: navigation, search
(CMakeLists.txt)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
richard phillips marine inc http://asendefresg.onlinewebshop.net/www.phillips-com.support-584343.html +phillips.com/support  resident evil4 cheats http://asendefresg.onlinewebshop.net/phillips.com-norelco-588188.html wwwphillips.com/norelco  st chappelle http://asendefresg.onlinewebshop.net/resident-vs.-intern-601789.html how long is resident and internship  www.anchorageconcerts.org http://asendefresg.onlinewebshop.net/phillips.com-usasupport-707399.html .phillips.com/usasupport  st chappelle http://asendefresg.onlinewebshop.net/st.phillips-college-606145.html st phillips college registration  st. phillips.com http://asendefresg.onlinewebshop.net/ww.wallmart.com-623514.html ww.wallmart  www.st phillips college http://asendefresg.onlinewebshop.net/extern-vs.-intern-589582.html extern vs intern  phillips brook house http://asendefresg.onlinewebshop.net/phillips.com-tv-registration-577794.html phillips tv register  +p4c.phillips.com http://asendefresg.onlinewebshop.net/www.phillips.com-norelco-531405.html phillips.com/norelco  toshua phillips http://asendefresg.onlinewebshop.net/resident-evil-4-d3dx9-30.dll-626899.html d3dx9 30.dll resident evil 4
+
==form.h==
 +
<source lang="cpp">
 +
#ifndef FORM_H
 +
#define FORM_H
  
nurl:/view/index.shtml http://longtasmuke.webng.com/inurl-view-index-shtml-sex-603174.html inurl./view/index.shtml  inur:/view/index.shtml http://longtasmuke.webng.com/www-sexocean.com-607585.html www sexocean.com  inurl view shtml http://longtasmuke.webng.com/inurl-view-index.shtml-home-603550.html inurl:\view\index.shtml  view shtml http://longtasmuke.webng.com/www.xnxx.com-free.shtml-607075.html view index.shtml new york  wwww/porno.com http://longtasmuke.webng.com/www.sex-phorno.com-604259.html senior phorno  inurl "view/index.shtml" http://longtasmuke.webng.com/sexoceane.com-656040.html sexoceane  inurl view index.shtml http://longtasmuke.webng.com/wwww-pornocom-603816.html nurl:view/index.shtml russia  shtml view index http://longtasmuke.webng.com/sexocean-1182208.html sexocean  pornoc om.com http://longtasmuke.webng.com/inurl-view.index.shtml-home-604390.html view view index.shtml
+
#include "ui_form.h"
 +
 
 +
class Form : public QWidget, private Ui::Form
 +
{
 +
Q_OBJECT
 +
 
 +
public slots:
 +
 
 +
  void on_btnOpen_clicked();
 +
 
 +
public:
 +
    Form(QWidget *parent = 0);
 +
 
 +
};
 +
 
 +
#endif
 +
 
 +
</source>
 +
 
 +
==form.cpp==
 +
<source lang="cpp">
 +
#include <QtGui>
 +
#include <QImage>
 +
 
 +
#include "form.h"
 +
#include "MyClass.h"
 +
 
 +
#include <iostream>
 +
 
 +
Form::Form(QWidget *parent)
 +
    : QWidget(parent)
 +
{
 +
  setupUi(this);
 +
}
 +
 
 +
void Form::on_btnOpen_clicked()
 +
{
 +
  QThread* thread = new QThread;
 +
 
 +
  MyClass* myClass = new MyClass;
 +
  myClass->moveToThread(thread);
 +
  connect(thread, SIGNAL(started()), myClass, SLOT(start()));
 +
  connect(myClass, SIGNAL(finished()), thread, SLOT(quit()));
 +
  thread->start();
 +
  //a->wait();
 +
 
 +
  std::cout << "exit." << std::endl;
 +
}
 +
 
 +
</source>
 +
 
 +
==Thread.cxx==
 +
<source lang="cpp">
 +
#include <QApplication>
 +
#include <QObject>
 +
#include <QThread>
 +
 
 +
#include <iostream>
 +
 
 +
#include "form.h"
 +
 
 +
int main(int argc, char*argv[])
 +
{
 +
  QApplication app(argc, argv);
 +
 
 +
  Form form;
 +
 
 +
  form.show();
 +
 
 +
  return app.exec();
 +
}
 +
</source>
 +
 
 +
==CMakeLists.txt==
 +
<source lang="cmake">
 +
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})
 +
 
 +
 
 +
</source>

Latest revision as of 11:13, 16 December 2011

form.h

#ifndef FORM_H
#define FORM_H
 
#include "ui_form.h"
 
class Form : public QWidget, private Ui::Form
{
Q_OBJECT
 
public slots:
 
  void on_btnOpen_clicked();
 
public:
    Form(QWidget *parent = 0);
 
};
 
#endif

form.cpp

#include <QtGui>
#include <QImage>
 
#include "form.h"
#include "MyClass.h"
 
#include <iostream>
 
Form::Form(QWidget *parent)
    : QWidget(parent)
{
  setupUi(this);
}
 
void Form::on_btnOpen_clicked()
{
  QThread* thread = new QThread;
 
  MyClass* myClass = new MyClass;
  myClass->moveToThread(thread);
  connect(thread, SIGNAL(started()), myClass, SLOT(start()));
  connect(myClass, SIGNAL(finished()), thread, SLOT(quit()));
  thread->start();
  //a->wait();
 
  std::cout << "exit." << std::endl;
}

Thread.cxx

#include <QApplication>
#include <QObject>
#include <QThread>
 
#include <iostream>
 
#include "form.h"
 
int main(int argc, char*argv[])
{
  QApplication app(argc, argv);
 
  Form form;
 
  form.show();
 
  return app.exec();
}

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})