aboutsummaryrefslogtreecommitdiffstats
path: root/doc/property.rst
blob: 88db8d68ef48434d926df69620b1b5b6c97ea84e (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
Use of QProperty in PySide
**************************

PySide implements the function 'QProperty' which allows to declare properties compatible with QMetaProperties.


Using PySide.QProperty()
------------------------

The QProperty works like Q_PROPERTY macro, and uses the same arguments.

QProperty(getFunction, [setFunction], [resetFunction], [Designable], [Scriptable], [Stored], [User])


The example below uses QProperty function to export a property in QMetaObject data.

::

    ...
    clas MyObject(QObject):
        def getX(self):
            ...

        def setX(self, value):
            ...

        def resetX(self):
            ...

        X = QProperty(getX, setX, resetX, True, True, True, True)

    ...


The exported property works like native python property on python side. See the example below.

::

    ...
    o = MyObject()
    o.X = 10
    print o.X
    ...