错误:'(QMessageBox::Icon)1u' cannot be used as a function

来源:互联网 发布:数据库系统概论萨师煊 编辑:程序博客网 时间:2024/04/27 23:56

程序代码如下:

<span style="font-size:18px;background-color: rgb(255, 255, 255);">void MainWindow::on_commandLinkButton_clicked()</span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);">{</span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>if(this->currentImage == 4)            </span>
</pre><pre class="cpp" name="code">
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>this->currentImage = 0;       </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>else            </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>this->currentImage ++;//更新当前图片       </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>QString fileName = list.at(this->currentImage);        </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>if(!fileName.isEmpty())      //图片是否存在        </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>{           </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>QImage image(fileName);            </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>if(image.isNull())            </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>{                </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>QMessageBox::Information(this,tr("Image Viewer"),tr("Cannot load %1.").arg(fileName));                </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>return;            </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>}            </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>ui->imageLabel->setPixmap(QPixmap::fromImage(image));  //用图片填充imageLabel        </span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);"><span style="white-space:pre"></span>}</span>
<span style="font-size:18px;background-color: rgb(255, 255, 255);">}</span>


 

编译报错:

/home/xiaofeng/qt/CommandLinkButton/ComLinButton/mainwindow.cpp:48:

错误:'(QMessageBox::Icon)1u' cannot be used as a function

 

进过分析发现:

<span style="background-color: rgb(255, 255, 255);"><span style="font-size:18px;">QMessageBox::Information(this,tr("Image Viewer"),tr("Cannot load %1.").arg(fileName));</span></span>

中的,Information有问题,应该是information,没注意首字母大小写,QMessageBox::information,才是静态成员函数

0 0
原创粉丝点击