aboutsummaryrefslogtreecommitdiff
path: root/sandbox/multithreading-tests/old-property-in-thread/thread.h
blob: 7999414161ef59435e188d81539592a223f9d93c (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 Q_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() << "Thread::run(), and current thread is" << QThread::currentThread();
            Listener listener;
            exec();
        }

};

#endif