Question

I would like to write a QML Extension using only Python. I know how to do this in C++, but not in Python. Is this even possible? Here's a vague idea of what I'm looking for.

class NewToQML(QObject):
    Q_PROPERTY(int root READ num WRITE setNum NOTIFY numChanged REVISION 1)

And in test.qml:

import MyQmlAdditions 1.0
NewToQML {
    num: 7;
}

[edit] I would like to use this QML addition to accomplish for instance changing the cursor when the mouse is over the graphical object (NewToQML).

Was it helpful?

Solution

I found the answer a while back on nabble answered by Phil Thompson-5 with a good explanation/reasoning following by Giovanni Bajo.

Short answer: PyQt does not support qmlRegisterType as of 4.7 and earlier versions.

However, PySide does have this functionality as shown here.

OTHER TIPS

If you installed the examples and demos with PyQt, the Minehunt demo provides a QML example. If you don't have it installed, download the PyQt4 source and look in examples/demos/declarative/minehunt.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top