aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2024-05-14 16:47:40 +0800
committerMitch Curtis <mitch.curtis@qt.io>2024-05-20 13:37:23 +0800
commita673fa92fb0fb79b891f1f4e4e8abf114afe0417 (patch)
treefca6db59f9ed32e33efa6fa110a8882d7b678f85
parente4577eb6bb9308d2b84bfe66216333b001ac670b (diff)
Doc: explain that Window doesn't apply palette.window automatically
Fixes: QTBUG-124357 Pick-to: 6.5 6.7 Change-Id: Id899833d750fab69c0ca7c2a7a01d9e1f109e0e5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r--src/quick/doc/snippets/qml/windowPalette.qml2
-rw-r--r--src/quick/items/qquickwindow.cpp18
2 files changed, 17 insertions, 3 deletions
diff --git a/src/quick/doc/snippets/qml/windowPalette.qml b/src/quick/doc/snippets/qml/windowPalette.qml
index 0638213c57..5a9219c638 100644
--- a/src/quick/doc/snippets/qml/windowPalette.qml
+++ b/src/quick/doc/snippets/qml/windowPalette.qml
@@ -17,12 +17,14 @@ Window {
palette.active.window: "peachpuff"
palette.windowText: "brown"
+//![text-item]
Text {
anchors.centerIn: parent
// here we use the Window.active attached property and the Item.palette property
color: Window.active ? palette.active.windowText : palette.inactive.windowText
text: Window.active ? "active" : "inactive"
}
+//![text-item]
Button {
text: "Button"
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 9db4174af0..eb969e7476 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -957,9 +957,21 @@ void QQuickWindowPrivate::cleanup(QSGNode *n)
// or to cancel the closing.
\endcode
- \note If using \l {Qt Quick Controls}, it's recommended to use
- \l ApplicationWindow instead of Window, as it has better styling
- support.
+ \section1 Styling
+
+ As with all visual types in Qt Quick, Window supports
+ \l {palette}{palettes}. However, as with types like \l Text, Window does
+ not use palettes by default. For example, to change the background color
+ of the window when the operating system's theme changes, the \l color must
+ be set:
+
+ \snippet qml/windowPalette.qml declaration-and-color
+ \codeline
+ \snippet qml/windowPalette.qml text-item
+ \snippet qml/windowPalette.qml closing-brace
+
+ Use \l {ApplicationWindow} (and \l {Label}) from \l {Qt Quick Controls}
+ instead of Window to get automatic styling.
*/
/*!