Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 无法加载QLabel背景的图像_Qt - Fatal编程技术网

Qt 无法加载QLabel背景的图像

Qt 无法加载QLabel背景的图像,qt,Qt,我的qrc文件定义如下: <RCC> <qresource prefix="/images"> <file>Resources/images/background.png</file> .... 但它不能将图像设置为背景。 知道为什么label无法加载图像吗?找不到图像 谢谢您说过您想要资源/images/background.png文件的/images前缀,因此在资源系统中该文件可以作为 :/images/Res

我的qrc文件定义如下:

<RCC>
    <qresource prefix="/images">
        <file>Resources/images/background.png</file>
    ....
但它不能将图像设置为背景。 知道为什么label无法加载图像吗?找不到图像


谢谢

您说过您想要
资源/images/background.png
文件的
/images
前缀,因此在资源系统中该文件可以作为

:/images/Resources/images/background.png
如果还要简化文件路径,请使用别名:

<file alias="background.png">Resources/images/background.png</file>
将来,学习如何自己调试这些简单的问题:只需将

QDirIterator i(":/", QDirIterator::Subdirectories);
while (i.hasNext())
    qDebug() << i.next();
QDirIterator i(“:/”,QDirIterator::子目录);
while(i.hasNext())

好的,谢谢,我会检查的。我发现有些人在某处绘制UI并使用资源文件。一个人和CSS混合使用C++很容易,浪费时间在团队合作上。
:/images/background.png
QDirIterator i(":/", QDirIterator::Subdirectories);
while (i.hasNext())
    qDebug() << i.next();