Documentation: Clarify palette/font/stylesheet inheritance/propagation

Palette and font changes made by a style sheet are propagated to
existing widgets and their children at change time.

Palette and font changes made by setPalette() and setFont() are
inherited by all existing and future children of the widget to which the
call was made.

Clarify this in the documentation.

Fixes: QTBUG-122588
Pick-to: 6.6 6.5 6.2 5.15
Change-Id: Ic40d96fc1e5e4507f84a33138303b7193948d3fe
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit f2b681dc590c7fd3cd19cbde20363339ceae15f8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Axel Spoerl 2024-03-14 08:48:56 +01:00 committed by Qt Cherry-pick Bot
parent 28911a81d4
commit 359b648280
2 changed files with 16 additions and 7 deletions

View File

@ -204,9 +204,9 @@
\value AA_UseStyleSheetPropagationInWidgetStyles By default, Qt Style Sheets
disable regular QWidget palette and font propagation. When this flag
is enabled, font and palette changes propagate as though the user had
manually called the corresponding QWidget methods. See
\l{The Style Sheet Syntax#Inheritance}{The Style Sheet Syntax - Inheritance}
is enabled, font and palette changes done from a style sheet will propagate
a single time, when the style sheet is set.
See \l{The Style Sheet Syntax#Inheritance}{The Style Sheet Syntax - Inheritance}
for more details.
This value was added in Qt 5.7.

View File

@ -480,11 +480,20 @@
\snippet code/doc_src_stylesheet.cpp 96
When the widget-style font and palette propagation is enabled, font and
palette changes made through Qt Style Sheets will behave as though the
user had manually called the corresponding QWidget::setPalette() and
palette changes made through Qt Style Sheets will behave as if the user
had manually called the corresponding QWidget::setPalette() and
QWidget::setFont() methods on all of the QWidgets targeted by the style
sheet. If this would have caused propagation in C++, it will cause
propagation in style sheets and vice versa.
sheet.
\list
\li Changes made by a style sheet are propagated.
They are pushed to all widgets matching the style sheet once, at the time
the change is made.
\li Changes made by calling QWidget::setPalette() or QWidget::setFont() are
inherited.
They are inherited by all existing and future children, where the respective
brush or font hasn't been explicitly set.
\endlist
\section1 Widgets Inside C++ Namespaces