[英]Change QML Image source from C++
if you look at my sample below I can alter the properties of QML objects from my C++ code using QT.如果您查看下面的示例,我可以使用 QT 从我的 C++ 代码中更改 QML 对象的属性。
C++ C++
QQuickItem* objectimage = quickView->rootObject();
QObject *im = objectimage->findChild<QObject*>("rect");
im->setProperty("color", "red");
QML质量管理语言
Image {
objectName: "ima"
id:pic
source: "bgnight.png"
Rectangle{
objectName: "rect"
id:redRect1
width: 100
height: 100
x: 130
y:230
color:"transparent"
My question is how do you change the source of an image in the same way from C. I would like to change the background image of QML from C++.我的问题是你如何以相同的方式从 C 更改图像的来源。我想从 C++ 更改 QML 的背景图像。
Image
{
property string src: "bge.png"
source: src
objectName: "ima"
id:pic
}
Qt 只有 C++ api,但您可以创建具有 C 函数定义但具有 C++ 实现的单独包装库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.