Page MenuHomePhorge

No OneTemporary

Size
6 KB
Referenced Files
None
Subscribers
None
diff --git a/.gitignore b/.gitignore
index 481cd36..a883a6c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/Version_Max_07_05_2018_CMake/QtProject/build-QtCAM-Desktop_Qt_5_11_2_GCC_64bit-Debug
+/Version_Max_07_05_2018_CMake/build-QTMultithreading-Desktop_Qt_5_11_2_GCC_64bit-Debug
diff --git a/Version_Max_07_05_2018_CMake/QTMultithreading/.gitignore b/Version_Max_07_05_2018_CMake/QTMultithreading/.gitignore
new file mode 100644
index 0000000..fab7372
--- /dev/null
+++ b/Version_Max_07_05_2018_CMake/QTMultithreading/.gitignore
@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+
diff --git a/Version_Max_07_05_2018_CMake/QTMultithreading/QTMultithreading.pro b/Version_Max_07_05_2018_CMake/QTMultithreading/QTMultithreading.pro
new file mode 100644
index 0000000..384fe64
--- /dev/null
+++ b/Version_Max_07_05_2018_CMake/QTMultithreading/QTMultithreading.pro
@@ -0,0 +1,29 @@
+QT -= gui
+
+CONFIG += c++11 console
+CONFIG -= app_bundle
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ main.cpp \
+ worker.cpp \
+ threadcontroller.cpp
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+HEADERS += \
+ worker.h \
+ threadcontroller.h
diff --git a/Version_Max_07_05_2018_CMake/QTMultithreading/main.cpp b/Version_Max_07_05_2018_CMake/QTMultithreading/main.cpp
new file mode 100644
index 0000000..0405d45
--- /dev/null
+++ b/Version_Max_07_05_2018_CMake/QTMultithreading/main.cpp
@@ -0,0 +1,16 @@
+#include <QCoreApplication>
+#include <QThread>
+#include <QDebug>
+#include "threadcontroller.h"
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication a(argc, argv);
+ //ThreadController* ctrl = new ThreadController;
+ ThreadController ctrl;
+
+
+
+ qDebug() << "Finishd program";
+ return a.exec();
+}
diff --git a/Version_Max_07_05_2018_CMake/QTMultithreading/threadcontroller.cpp b/Version_Max_07_05_2018_CMake/QTMultithreading/threadcontroller.cpp
new file mode 100644
index 0000000..6336273
--- /dev/null
+++ b/Version_Max_07_05_2018_CMake/QTMultithreading/threadcontroller.cpp
@@ -0,0 +1,35 @@
+#include "threadcontroller.h"
+#include "worker.h"
+
+ThreadController::ThreadController(QObject *parent) : QObject(parent)
+{
+ Worker *worker = new Worker;
+ worker->moveToThread(&this->workerThread);
+ this->workerThread.setObjectName("workerThread");
+ connect(&this->workerThread,SIGNAL(finished()), worker, SLOT(deleteLater()));
+ connect(this, SIGNAL(finished()), &this->workerThread, SLOT(quit()));
+ connect(this, SIGNAL(finished()), worker, SLOT(deleteLater()));
+ connect(this, SIGNAL(operate(const QString&)), worker, SLOT(doParallelAlgorithm(const QString&)));
+ connect(worker, SIGNAL(resultReady(const QString&)), this, SLOT(handleResults(const QString&)));
+ connect(&this->workerThread, SIGNAL(finished()), this, SLOT(closeApplication()));
+ this->workerThread.start();
+ emit operate("doParallel Multitrheading");
+}
+
+
+ThreadController::~ThreadController()
+{
+
+}
+
+void ThreadController::handleResults(const QString& parameter)
+{
+ qDebug() << "Handling results";
+ qDebug() << parameter;
+ emit finished();
+}
+
+void ThreadController::closeApplication()
+{
+ QCoreApplication::quit();
+}
diff --git a/Version_Max_07_05_2018_CMake/QTMultithreading/threadcontroller.h b/Version_Max_07_05_2018_CMake/QTMultithreading/threadcontroller.h
new file mode 100644
index 0000000..8612b09
--- /dev/null
+++ b/Version_Max_07_05_2018_CMake/QTMultithreading/threadcontroller.h
@@ -0,0 +1,29 @@
+#ifndef THREADCONTROLLER_H
+#define THREADCONTROLLER_H
+
+#include <QObject>
+#include <QThread>
+#include <QDebug>
+#include <QCoreApplication>
+
+class ThreadController : public QObject
+{
+ Q_OBJECT
+public:
+ explicit ThreadController(QObject *parent = nullptr);
+ ~ThreadController();
+
+signals:
+ void operate(const QString& parameter);
+ void finished();
+
+public slots:
+ void handleResults(const QString& parameter);
+ void closeApplication();
+
+
+private:
+ QThread workerThread;
+};
+
+#endif // THREADCONTROLLER_H
diff --git a/Version_Max_07_05_2018_CMake/QTMultithreading/worker.cpp b/Version_Max_07_05_2018_CMake/QTMultithreading/worker.cpp
new file mode 100644
index 0000000..27bc08b
--- /dev/null
+++ b/Version_Max_07_05_2018_CMake/QTMultithreading/worker.cpp
@@ -0,0 +1,18 @@
+#include "worker.h"
+
+Worker::Worker(QObject *parent) : QObject(parent)
+{
+
+}
+
+void Worker::startThread()
+{
+ qDebug() << "Thread started, enjoy it.";
+ doParallelAlgorithm("Give some data to me");
+}
+
+void Worker::doParallelAlgorithm(const QString& data)
+{
+ qDebug() << data;
+ emit resultReady("ready to process data");
+}
diff --git a/Version_Max_07_05_2018_CMake/QTMultithreading/worker.h b/Version_Max_07_05_2018_CMake/QTMultithreading/worker.h
new file mode 100644
index 0000000..e9295b8
--- /dev/null
+++ b/Version_Max_07_05_2018_CMake/QTMultithreading/worker.h
@@ -0,0 +1,25 @@
+#ifndef WORKER_H
+#define WORKER_H
+
+#include <QObject>
+#include <QDebug>
+#include <QString>
+
+
+class Worker : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Worker(QObject *parent = nullptr);
+
+
+
+signals:
+ void resultReady(const QString& parameter);
+
+public slots:
+ void doParallelAlgorithm(const QString& data);
+ void startThread();
+};
+
+#endif // WORKER_H

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jul 3, 3:53 PM (23 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
157280
Default Alt Text
(6 KB)

Event Timeline