[Qt-qml] QML must love binding programmers

Hugo Parente Lima hugo.lima at openbossa.org
Mon Oct 25 23:18:54 CEST 2010


Hi;

I'm working on getting Python (PySide) able to export Python types to QML the 
same way you can do with C++ types, i.e.:

class Foo(QObject):
	...

qmlRegisterType(Foo, "foo.bar.com", 1, 0, "FooOnQml_huhu")

I took a look on QtDeclarative sources and faced some issues to integrate 
Python or any other language to QML.

First, QML uses qmlRegisterType<T> function to register a type, this function 
just fills a struct with some info and pass it to the depths of QML, one of 
these fields is a function pointer, this function pointer is used as a factory 
function by QML to create instances of the exported type T. So what's the 
problem?

Using a template function everything can be decided at compile time, so we 
have a different factory function for each type exported to QML, perfect for 
C++ but Qt bindings doesn't have the information about user created types at 
compile time, so we can't have a factory function for each type created by the 
user as we have on C++.

One way to ease the work of people doing Qt bindings to support QML is adding 
a bit more info on this factory function, so we can use a Proxy object to 
decide what type need to be instantiated.

I attached a pseudo-patch that implements this idea, pseudo because I wrote it 
just to show what changes are needed, if I get a thumbs up about it I can 
work, test and create a merge request for it.

Any comments? Any chances to get it or something like it into the mainline for 
Qt4.7.1?

-- 
Hugo Parente Lima
INdT - Instituto Nokia de Tecnologia
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Makes-possible-to-Qt-bindings-to-export-user-types-t.patch
Type: text/x-patch
Size: 1853 bytes
Desc: not available
Url : http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20101025/fe061561/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20101025/fe061561/attachment-0001.bin 


More information about the Qt-qml mailing list