【发布时间】:2017-03-06 21:26:11
【问题描述】:
我正在尝试在 QLabel 中显示资源文件中的图像。所有这一切都发生在一个扩展主要核心应用程序的插件中。
#include "sampleplugin.h"
#include <QtWidgets>
SamplePlugin :: SamplePlugin()
{
Q_INIT_RESOURCE(pluginresources);
oLContainerWidget = new QWidget();
olWrapper = new QHBoxLayout();
bagIcon(":/sample_plugin_resources/images/Dry-50.png");
oLContainerWidget -> setLayout(olWrapper);
}
void SamplePlugin :: testIcon(const QString &imageUrl)
{
QPixmap pix(imageUrl);
QLabel *sampleIconLabel = new QLabel();
sampleIconLabel -> setPixmap(pix);
olWrapper -> addWidget(sampleIconLabel);
}
项目编译没有任何错误,但图像不显示。我究竟做错了什么?
提前谢谢大家。
项目结构:
**plugins_dir**
sampleplugin
pluginresources.qrc
sample_plugin_resources
- Dry-50.png
【问题讨论】: