Open bjoernrennfanz opened 7 years ago
Hello,
i tried to call a QML function from C#. I have implemented a simple sample form QT See ref: http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html
But it does not work. Here is my code...
QQmlEngine engine = new QQmlEngine(); QQmlComponent component = new QQmlComponent(engine, QUrl.FromLocalFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "myitem.qml"))); QObject test1 = component.Create(); QVariant msg = "Hello from C++"; QVariant returnedValue = new QVariant(); bool test = QMetaObject.InvokeMethod(test1, "myQmlFunction", new QGenericReturnArgument("QVariant", returnedValue.Data) , new QGenericArgument("QVariant", msg.Data)); Console.Write(returnedValue.ToString());
The InvokeMethod always returns with "false". Have anybody a idea what is wrong?
Hello,
i tried to call a QML function from C#. I have implemented a simple sample form QT See ref: http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html
But it does not work. Here is my code...
The InvokeMethod always returns with "false". Have anybody a idea what is wrong?