程序代码如下:
void MainWindow::on_commandLinkButton_clicked()
{
if(this->currentImage == 4)
this->currentImage = 0;
else
this->currentImage ++;//更新当前图片
QString fileName = list.at(this->currentImage);
if(!fileName.isEmpty()) //图片是否存在
{
QImage image(fileName);
if(image.isNull())
{
QMessageBox::Information(this,tr("Image Viewer"),tr("Cannot load %1.").arg(fileName));
return;
}
ui->imageLabel->setPixmap(QPixmap::fromImage(image)); //用图片填充imageLabel
}
}
编译报错:
/home/xiaofeng/qt/CommandLinkButton/ComLinButton/mainwindow.cpp:48:
错误:'(QMessageBox::Icon)1u' cannot be used as a function
进过分析发现:
QMessageBox::Information(this,tr("Image Viewer"),tr("Cannot load %1.").arg(fileName));
中的,Information有问题,应该是information,没注意首字母大小写,QMessageBox::information,才是静态成员函数。
做个广告: