QT中如何在消息框中显示图标?
How to display icon in messagebox in QT?
我正在尝试根据 resources.qrc 文件中的图像“/newicon.png”在消息框中创建一个图标。但是,当我创建消息框时,图像不会出现。
我下面的代码可能有什么问题?
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>
更改您的前缀
<qresource prefix="/.">
至
<qresource prefix="/">
我正在尝试根据 resources.qrc 文件中的图像“/newicon.png”在消息框中创建一个图标。但是,当我创建消息框时,图像不会出现。
我下面的代码可能有什么问题?
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>
更改您的前缀
<qresource prefix="/.">
至
<qresource prefix="/">