[Interest] Why is this not working? Assign direct to QML (through setContextProperty) works, as function doesn't.

Alan Ezust alan.ezust at gmail.com
Fri Nov 9 01:01:23 CET 2012


On Thu, Nov 8, 2012 at 1:19 PM, Mark <markg85 at gmail.com> wrote:

>
> Note: i cannot do qRegisterMetaType on the PathModel since it's class
> that inherits from a class that forbids copying the data (copy
> constructor stuff).
>
>
qmlRegisterType can register classes derived from QObject. Although you're
actually going to register a pointer to that type, rather than the class
itself.
>From http://qt-project.org/doc/qt-4.8/qml-extending.html

Custom C++ types are registered using a template function:

 template<typename T>
 int qmlRegisterType
<http://qt-project.org/doc/qt-4.8/qdeclarativeengine.html#qmlRegisterType>(const
char *uri, int versionMajor, int versionMinor, const char *qmlName)

Calling qmlRegisterType<http://qt-project.org/doc/qt-4.8/qdeclarativeengine.html#qmlRegisterType>()
registers the C++ type *T* with the QML system, and makes it available in
QML under the name *qmlName* in library *uri* version *
versionMajor.versionMinor*. The *qmlName* can be the same as the C++ type
name.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121108/b538b455/attachment.html>


More information about the Interest mailing list