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