1
我试图从我的resources.qrc文件中的图像“/newicon.png”的消息框中创建一个图标。但是,当我创建消息框时,图像不会显示。如何在QT中的消息框中显示图标?
下面的代码会出现什么问题?
void MainWindow::aboutClicked(){
QMessageBox messageBox;
messagebox.setIconPixmap(QPixmap(":/newicon.png"));
messageBox.setText("hello this is the message box");
messageBox.setWindowTitle("About");
messageBox.exec();
}
编辑: 更多信息有关resources.qrc文件:
<RCC>
<qresource prefix="/.">
<file>button.png</file>
<file>newicon.png</file>
</qresource>
</RCC>
感谢更改前缀,我错误地包含全因为教程我readi ng在句子末尾放置“/”! – user40990