gpt4 book ai didi

c++ - 协议(protocol) C 是 qml 中的未知错误

转载 作者:太空狗 更新时间:2023-10-29 20:27:00 26 4
gpt4 key购买 nike

我有一个 qml 文件,这里是源代码:

import QtQuick 2.0

Image
{
id: imageIcon;

width: 100;
height: 100;

source: 'C:/Users/Public/Pictures/Sample Pictures/Chrysanthemum.jpg';
}

当我在 QQuickView 上显示它时出现此错误:

QML Image: Protocol "c" is unknown

如果相关,我将在 Windows 7 上运行代码。

url 的正确格式是什么?

最佳答案

看起来源代码必须使用格式正确的 URL:它需要 file:// 方案或 qrc://(用于 Qt 资源中的内容)

你的文件解析尝试使用未知的“C”协议(protocol)(来自 C:/):尝试

source: 'file:///C:/Users/Public/Pictures/Sample Pictures/Chrysanthemum.jpg';

参见:http://harmattan-dev.nokia.com/docs/platform-api-reference/xml/daily-docs/libqt4/qml-url.html

通常您希望图像相对(部署在您的应用附近)或嵌入到资源中,而不是绝对引用,因为这会破坏部署。

关于c++ - 协议(protocol) C 是 qml 中的未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17610949/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com