C++ GUI using QT

Posted by user1488019 on Stack Overflow See other posts from Stack Overflow or by user1488019
Published on 2012-06-28T09:14:24Z Indexed on 2012/06/28 9:15 UTC
Read the original article Hit count: 180

Filed under:

I want to build a c++ GUI using Qt plaform. this a part of my code which is about opening an image file. i used this method to open the image, but when i choose it from a specific folder nothing is shown (no image).

void MainWindow::openI()
{
QString fileName = QFileDialog::getOpenFileName(this,
                                tr("Open File"), QDir::currentPath());
if (!fileName.isEmpty()) {
    QImage image(fileName);
    if (image.isNull()) {
        QMessageBox::information(this, tr("Image Viewer"),
                                 tr("Cannot load %1.").arg(fileName));
        return;
    }

  }

}

Please help me!! this is a small part of my project

© Stack Overflow or respective owner

Related posts about c++