-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainclass.cpp
More file actions
25 lines (18 loc) · 890 Bytes
/
mainclass.cpp
File metadata and controls
25 lines (18 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "mainclass.h"
#include <QThread>
MainClass::MainClass(QObject *parent)
: QObject{parent}
{
tsk=new Task();
taskThread=QThread::create(&Task::printMessage,tsk,"hello bitches");
connect(taskThread,&QThread::finished,this,&QCoreApplication::quit,Qt::QueuedConnection);
connect(this,&MainClass::sendMess,tsk,&Task::printMessage,Qt::QueuedConnection);
}
void MainClass::runTest()
{
qDebug()<<"Main thread id: "<<QThread::currentThreadId();
taskThread->start();
//слот, связанный с этим сигналом запустится в главном потоке, что подтверждает теорию, о том, что данный способ создания потока не порождает цикл событий и не может
//работать с доп. сигналами
emit sendMess("infoinfo");
}