3
如何在消息框中显示图像。我试过在QmessageBox中显示图像
about.setIcon(":/pics/goku3.jpg");
但它给了我错误。我知道我可以使用内置的关于盒子。以下是显示有关框的完整代码。
void MainWindow::on_actionUmer_s_Program_triggered()
{
QMessageBox about;
about.setText("Umer's Program");
about.setInformativeText("Copyright ; 2012 Umer Software Inc.\nI wrote this program for fun.\n);
about.setStandardButtons(QMessageBox::Ok);
about.setIcon(":/pics/goku3.jpg"); // here is the error
about.setDefaultButton(QMessageBox::Ok);
about.show();
about.exec();
}
请同时告诉我如何设置该图像的大小。
我该如何调整图标大小。 – 2012-03-07 13:12:01
调整图像本身大小的最佳方式 但是,如果您想从代码执行此操作,请创建一个新的像素图 QPixmap myPixmap(30,30); (大小) ,然后加载图像: myPixmap.load(filename); 更多信息在这里http://qt-project.org/doc/qt-4.8/qpixmap.html#pixmap-information – Stely 2012-03-07 15:54:43