examples: compile w/QT_NO_CAST_FROM_BYTEARRAY, at least on Unix
authorMarc Mutz <marc.mutz@kdab.com>
Thu, 23 Feb 2012 06:39:45 +0000 (07:39 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 8 Mar 2012 08:58:26 +0000 (09:58 +0100)
This is all pretty straight-forward, adding .constData() or
using QString::fromLatin1() instead of QLatin1String().

Change-Id: I984706452db7d0841620a0f64e179906123f3849
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
examples/desktop/screenshot/screenshot.cpp
examples/tools/codecs/mainwindow.cpp
examples/touch/fingerpaint/mainwindow.cpp
examples/widgets/scribble/mainwindow.cpp
examples/widgets/stylesheet/stylesheeteditor.cpp

index 7773728..66467d4 100644 (file)
@@ -102,7 +102,7 @@ void Screenshot::saveScreenshot()
                                .arg(format.toUpper())
                                .arg(format));
     if (!fileName.isEmpty())
-        originalPixmap.save(fileName, format.toAscii());
+        originalPixmap.save(fileName, format.toAscii().constData());
 }
 //! [3]
 
index 8f3c94e..4adff6d 100644 (file)
@@ -99,7 +99,7 @@ void MainWindow::save()
         QByteArray codecName = action->data().toByteArray();
 
         QTextStream out(&file);
-        out.setCodec(codecName);
+        out.setCodec(codecName.constData());
         out << textEdit->toPlainText();
     }
 }
index 288068f..be005cf 100644 (file)
@@ -206,12 +206,12 @@ bool MainWindow::saveFile(const QByteArray &fileFormat)
     QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
                                initialPath,
                                tr("%1 Files (*.%2);;All Files (*)")
-                               .arg(QString(fileFormat.toUpper()))
-                               .arg(QString(fileFormat)));
+                               .arg(QString::fromLatin1(fileFormat.toUpper()))
+                               .arg(QString::fromLatin1(fileFormat)));
     if (fileName.isEmpty()) {
         return false;
     } else {
-        return scribbleArea->saveImage(fileName, fileFormat);
+        return scribbleArea->saveImage(fileName, fileFormat.constData());
     }
 }
 //! [20]
index 4a59e93..00bf988 100644 (file)
@@ -239,12 +239,12 @@ bool MainWindow::saveFile(const QByteArray &fileFormat)
     QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
                                initialPath,
                                tr("%1 Files (*.%2);;All Files (*)")
-                               .arg(QString(fileFormat.toUpper()))
-                               .arg(QString(fileFormat)));
+                               .arg(QString::fromLatin1(fileFormat.toUpper()))
+                               .arg(QString::fromLatin1(fileFormat)));
     if (fileName.isEmpty()) {
         return false;
     } else {
-        return scribbleArea->saveImage(fileName, fileFormat);
+        return scribbleArea->saveImage(fileName, fileFormat.constData());
     }
 }
 //! [20]
index 88f5100..5514291 100644 (file)
@@ -85,7 +85,7 @@ void StyleSheetEditor::loadStyleSheet(const QString &sheetName)
 {
     QFile file(":/qss/" + sheetName.toLower() + ".qss");
     file.open(QFile::ReadOnly);
-    QString styleSheet = QLatin1String(file.readAll());
+    QString styleSheet = QString::fromLatin1(file.readAll());
 
     ui.styleTextEdit->setPlainText(styleSheet);
     qApp->setStyleSheet(styleSheet);