Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Add a method to all QML code
chrismit7 last edited by
I'm looking to provide a way to integrate QML with a lua environment. What I need to do is have a method callable by each element in QML that will in turn execute lua code. So something simple like:
element.callLua("string with lua code to execute");
I want every element to have this callLua method. Any advice? I'm coding in C++, so one option I've considered is to inherit every basic QML type and just add a method to it.
Add callLua as a Q_INVOKABLE method to some QObject-derived class, then add this class to root context property of the engine. It will then be available in all QML files you are using in your project.