diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-07-17 14:43:34 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-07-17 14:43:34 +0000 |
commit | dcc301abfa7b6535199d028ad1afc15daa2d1200 (patch) | |
tree | 44a4688bc490f0d57d31a361455b8bde1ffd3dbf /examples/widgets | |
parent | 5443da6c2795255db55697471190b3eba16b28dc (diff) | |
parent | b2603b76655ac819e43c063bb6f16bc95f358083 (diff) |
Merge "Merge remote-tracking branch 'origin/5.5' into HEAD" into refs/staging/dev
Diffstat (limited to 'examples/widgets')
-rw-r--r-- | examples/widgets/doc/src/imageviewer.qdoc | 14 | ||||
-rw-r--r-- | examples/widgets/gestures/imagegestures/imagewidget.cpp | 1 | ||||
-rw-r--r-- | examples/widgets/widgets/imageviewer/imageviewer.cpp | 4 |
3 files changed, 14 insertions, 5 deletions
diff --git a/examples/widgets/doc/src/imageviewer.qdoc b/examples/widgets/doc/src/imageviewer.qdoc index 901d6fe76e..91ae56b5d7 100644 --- a/examples/widgets/doc/src/imageviewer.qdoc +++ b/examples/widgets/doc/src/imageviewer.qdoc @@ -124,10 +124,16 @@ \snippet widgets/imageviewer/imageviewer.cpp 2 - In the \c loadFile() function, we check if the file's - format is an image format by constructing a QImage which tries to - load the image from the file. If the constructor returns a null - image, we use a QMessageBox to alert the user. + In the \c loadFile() function, we instantiate a QImageReader + and enable automatic transformations by calling + QImageReader::setAutoTransform(). For files in JPEG format, + this ensures that portrait mode images of digital cameras are shown + correctly by applying the appropriate orientation read from the + EXIF meta data stored in the image file. + + We then load the image using QImageReader::read(). If this returns + a null image, indicating that the file is not an image file, + we use a QMessageBox to alert the user. The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons. As with QFileDialog the diff --git a/examples/widgets/gestures/imagegestures/imagewidget.cpp b/examples/widgets/gestures/imagegestures/imagewidget.cpp index 3d0d7e7a93..440eb783c1 100644 --- a/examples/widgets/gestures/imagegestures/imagewidget.cpp +++ b/examples/widgets/gestures/imagegestures/imagewidget.cpp @@ -202,6 +202,7 @@ QImage ImageWidget::loadImage(const QString &fileName) { qDebug() << position << files << fileName; QImageReader reader(fileName); + reader.setAutoTransform(true); qCDebug(lcExample) << "loading" << QDir::toNativeSeparators(fileName) << position << '/' << files.size(); if (!reader.canRead()) { qCWarning(lcExample) << QDir::toNativeSeparators(fileName) << ": can't load image"; diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp index 0b8513f090..93b88e9c18 100644 --- a/examples/widgets/widgets/imageviewer/imageviewer.cpp +++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp @@ -69,7 +69,9 @@ ImageViewer::ImageViewer() bool ImageViewer::loadFile(const QString &fileName) { - QImage image(fileName); + QImageReader reader(fileName); + reader.setAutoTransform(true); + const QImage image = reader.read(); if (image.isNull()) { QMessageBox::information(this, QGuiApplication::applicationDisplayName(), tr("Cannot load %1.").arg(QDir::toNativeSeparators(fileName))); |