blob: dd9951b372141f0ff54610d91c421060885dc8c9 (
plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#ifndef THREAD_H
#define THREAD_H
#include <contextproperty.h>
#include <QThread>
#include <QDebug>
class Listener : public QObject
{
Q_OBJECT
public:
Listener()
{
cp = new ContextProperty("test.int");
connect(cp, SIGNAL(valueChanged()), this, SLOT(onValueChanged()));
}
ContextProperty* cp;
public slots:
void onValueChanged()
{
qDebug() << "Listener::valueChanged(), and current thread is" << QThread::currentThread();
qDebug() << "The value is:" << cp->value();
exit(1);
}
};
class Thread : public QThread
{
Q_OBJECT
protected:
void run()
{
qDebug() << "SUB THREAD:" << QThread::currentThread();
Listener listener;
exec();
}
};
#endif
|