Calling c++ method from QML.
Solved
General and Desktop
-
Hi
I am trying to call a c++ method from a qml but I am not able to do so because of the error: undefined reference to 'vtable for Example'.My Code:
example.h
class Example: public QObject { Q_OBJECT public: explicit Example(QObject *parent = 0); Q_INVOKABLE bool example_method(int ); }
example.cpp
Example::Example(QObject *parent) : QObject(parent) {} bool Example::example_method() { ... }
main.cpp
int main() { ... Example adjust; engine.rootContext()->setContextProperty("example", &example); ... }
main.qml
Slider { ... onValueChanged: { example.example_method(value) } }
Please help how to fix this problem ?