June 11, 2010

Qt QML setContextProperty

In order to use a C++ Class function in your QML file, you can expose the class itself using setContextProperty("myvar",pointer_to_your_class_instance), then call myvar.func() in your QML file. However, there is a trick to get this to work.

In your class definition file, these functions have to been exposed as "public Q_SLOTS:", otherwise QML cannot see it.

No comments:

Post a Comment