summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2018-09-12 11:50:16 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2018-09-25 12:15:36 +0000
commit213cfc3faee121411fcaac9f99bb5ffd94429384 (patch)
tree222db7612f1c9e318afd6e670b9c541a65abca97 /examples
parentd0528d558e1475cf43279177e4cdad0bd799e806 (diff)
Make the textedit example use dark text on light background on macOS
Many text documents will be designed for a white-paper look, and in these cases it is desirable that the editor colors matches. Change-Id: I66d721f8c2e27b78a2b885c6cfd74f897fe42389 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp
index 0cc5204675..0d51ce61ad 100644
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ b/examples/widgets/richtext/textedit/textedit.cpp
@@ -150,6 +150,14 @@ TextEdit::TextEdit(QWidget *parent)
textEdit->setFocus();
setCurrentFileName(QString());
+
+#ifdef Q_OS_MACOS
+ // Use dark text on light background on macOS, also in dark mode.
+ QPalette pal = textEdit->palette();
+ pal.setColor(QPalette::Base, QColor(Qt::white));
+ pal.setColor(QPalette::Text, QColor(Qt::black));
+ textEdit->setPalette(pal);
+#endif
}
void TextEdit::closeEvent(QCloseEvent *e)