将C ++或JS函数写入QML [英] Write C++ or JS function into QML

查看:70
本文介绍了将C ++或JS函数写入QML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个QML文件,我正在显示我的网络设备的更新。

I have a QML file where i am displaying update of my device of the network.

Text{
    x: 110; y: 84
    text : pIso.gVolt(pIso.gVolt); color : "white"; font.pointSize: 6; textFormat: Text.StyledText


    onTextChanged: {
//here I want to add the code to write update value of device into log file(CSV)
}
}



我想要我需要调用C ++函数或直接在QML文件中添加代码以便编写并附加到日志文件中。??

是否可以使用Java脚本执行此操作?



我尝试过:



这是我第一次与...互动QML。我不知道如何在QML文件中挂钩c ++


I want to get the idea do I need to call the C++ function OR Add code directly in QML file for writing and appending into log file.??
Is it possible to do this with Java script??

What I have tried:

This is first time i am interacting with QML. I dont know how to hook c++ in QML file

推荐答案

如果你想写一些文件数据你不能使用javascript。所以使用C ++。 C ++需要运行可执行文件。



阅读 Qt文档并查看一些示例代码。祝你好运。
If you want to write some file data you cant use javascript. So use C++. The C++ needs an executable to run.

Read the Qt documentation and look at some sample code. Good luck.


这篇关于将C ++或JS函数写入QML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆