summaryrefslogtreecommitdiff
path: root/examples/qtobject/testobject.h
blob: 72e57bb196096e7f9407334021fafa32f2f4e266 (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
46
47
48
49
50
51
52
53
#ifndef TESTOBJECT_H
#define TESTOBJECT_H

#include <QObject>
#include <QtDebug>
#include <QTimer>

class TestObject : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
    Q_PROPERTY(QString prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed)
public:
    explicit TestObject(QObject *parent = 0);
    QString prop1() const { return "p1" + p1 + objectName(); }
    void setProp1(const QString& s);

    QString prop2() const { return "p2" +  p2 + objectName(); }
    void setProp2(const QString& s);

signals:
    void timeout();
    void sig1(int a, float b, const QString& c);
    void sig2();
    void prop1Changed();
    void prop2Changed(const QString& newValue);

public slots:
    void startTimer(int millis)
    {
        timer.start(millis);
    }

    QString debugMe(const QString& data);

    QString manyArgs(int a, float b, const QString& c) const;

private:
    QString p1;
    QString p2;
    QTimer timer;
};

class TestObjectFactory : public QObject
{
    Q_OBJECT
public:
    explicit TestObjectFactory(QObject* parent = 0);

    Q_INVOKABLE TestObject* createObject(const QString& name);
};

#endif // TESTOBJECT_H