summaryrefslogtreecommitdiffstats
path: root/examples/widgets/richtext
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/richtext')
-rw-r--r--examples/widgets/richtext/orderform/mainwindow.cpp2
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp10
2 files changed, 6 insertions, 6 deletions
diff --git a/examples/widgets/richtext/orderform/mainwindow.cpp b/examples/widgets/richtext/orderform/mainwindow.cpp
index 0b6a2cac6c..ee6758c9cb 100644
--- a/examples/widgets/richtext/orderform/mainwindow.cpp
+++ b/examples/widgets/richtext/orderform/mainwindow.cpp
@@ -248,7 +248,7 @@ void MainWindow::openDialog()
//! [17]
void MainWindow::printFile()
{
-#if QT_CONFIG(printdialog)
+#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QTextEdit *editor = static_cast<QTextEdit*>(letters->currentWidget());
//! [18]
QPrinter printer;
diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp
index efeaf75cc5..5d27e7df0c 100644
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ b/examples/widgets/richtext/textedit/textedit.cpp
@@ -419,18 +419,18 @@ bool TextEdit::load(const QString &f)
QByteArray data = file.readAll();
QTextCodec *codec = Qt::codecForHtml(data);
QString str = codec->toUnicode(data);
- QUrl baseUrl = (f.front() == QLatin1Char(':') ? QUrl(f) : QUrl::fromLocalFile(f)).adjusted(QUrl::RemoveFilename);
- textEdit->document()->setBaseUrl(baseUrl);
if (Qt::mightBeRichText(str)) {
+ QUrl baseUrl = (f.front() == QLatin1Char(':') ? QUrl(f) : QUrl::fromLocalFile(f)).adjusted(QUrl::RemoveFilename);
+ textEdit->document()->setBaseUrl(baseUrl);
textEdit->setHtml(str);
} else {
#if QT_CONFIG(textmarkdownreader)
QMimeDatabase db;
if (db.mimeTypeForFileNameAndData(f, data).name() == QLatin1String("text/markdown"))
- textEdit->setMarkdown(str);
+ textEdit->setMarkdown(QString::fromUtf8(data));
else
#endif
- textEdit->setPlainText(QString::fromLocal8Bit(data));
+ textEdit->setPlainText(QString::fromUtf8(data));
}
setCurrentFileName(f);
@@ -545,7 +545,7 @@ bool TextEdit::fileSaveAs()
void TextEdit::filePrint()
{
-#if QT_CONFIG(printdialog)
+#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
QPrinter printer(QPrinter::HighResolution);
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (textEdit->textCursor().hasSelection())