且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Qt QRC资源文件-无法加载图标

更新时间:2023-09-26 21:00:52

@Nikos C.为您提供了有用的建议,但是我认为您的主要问题是您没有使用正确的资源链接.

@Nikos C. gives you useful advice, but I think your main problem was that you didn't use the correct link to the resource.

在您的代码中,您拥有:

In your code, you have:

QPixmap pixmap = QPixmap ("://my_image.png");

但是,根据文档,它应该是>

but, according to the documentation, it should be

QPixmap pixmap = QPixmap (":/my_image.png");

或者您可以为资源指定别名,而改用这些别名.

or you can give aliases to your resources, and use those instead.