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

Mark markg85 at gmail.com
Fri Nov 9 02:33:56 CET 2012

On Fri, Nov 9, 2012 at 1:01 AM, Alan Ezust <alan.ezust at gmail.com> wrote:
> 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(const char *uri, int versionMajor, int versionMinor,
> const char *qmlName)
> Calling 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.

Hi Alan,

Thank you for your reply.
I do wonder though, isn't qmlRegisterType for registering custom QML
elements? Since that's not what i'm trying to do. I only try to make
an object usable in QML. Something that works if i send it to QML
directly using setContextProperty but doesn't work if i send a class
and call a function with the object i want (the function pathModel()
in the example from my first post.

More information about the Interest mailing list