From f54e97726f36c56d9f51f2243493c55ab8cf7bef Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Wed, 30 Oct 2019 10:50:41 +0100 Subject: Doc: Add notes about Qt Style Sheets taking precedence ...over setting properties on individual widgets. Task-number: QTBUG-28675 Change-Id: Ic7bfd723ed8970112a9892727170d3bacaa1903f Reviewed-by: Frederik Gladhorn --- src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/widgets/doc') diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index 00323eace6..12e27a71ad 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -59,6 +59,11 @@ \li \l{Qt Style Sheets Examples} \endlist + \note If Qt Style Sheets are used on the same widget as functions that + set the appearance of widgets, such as \l QWidget::setFont() or + \l QTreeWidgetItem::setBackground(), style sheets will take precedence + if the settings conflict. + \target overview \section1 Overview -- cgit v1.2.3 From 41702d8455a9e88ac70108e500a10e7bd4df2771 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 21 Oct 2019 21:23:08 +0200 Subject: Honor alpha for SH_Table_GridLineColor Make sure to honor the alpha channel for the color returned by SH_Table_GridLineColor. Fixes: QTBUG-74909 Change-Id: If9688329e5e2ab41833dfeb7e6292fdfcbf63aa1 Reviewed-by: Richard Moe Gustavsen --- src/widgets/doc/snippets/javastyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/doc') diff --git a/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp index 8657d5ed29..3d1b1e0030 100644 --- a/src/widgets/doc/snippets/javastyle.cpp +++ b/src/widgets/doc/snippets/javastyle.cpp @@ -2589,7 +2589,7 @@ int JavaStyle::styleHint(StyleHint hint, const QStyleOption *option, switch (hint) { case SH_Table_GridLineColor: { - ret = static_cast(option->palette.color(QPalette::Mid).rgb()); + ret = static_cast(option->palette.color(QPalette::Mid).rgba()); break; } case QStyle::SH_Menu_Scrollable: -- cgit v1.2.3 From 01ec11507d7ef3de09bad9d1ef8e6d4a3d6c4428 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 10 Oct 2019 14:33:53 +0200 Subject: QStyleSheetStyle: add new property to QPushButton: icon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is currently no proper way to change the icon of a pushbutton from css. But there is a need for doing so (QTBUG-2982), and the typical work-around is to instead use the css property 'qproperty-icon'. But setting qproperties from the style is not a good idea in the first place, since it modifies the state of the widget it draws. Moreover, such properties are only set once (in QStyle::polish()), and will not have any effect on pseudo states, like hover. To close this gap, this patch will add a css property 'icon' that can be set on a QPushButton. This property will follow normal css cascading, and respect pseudo states, equal to any other css property. [ChangeLog][QtWidgets][QStyle] You can now set the CSS property 'icon' on a QPushButton to override which icon to draw. Fixes: QTBUG-79137 Change-Id: Ie7e0b0fa4f19471f51108cd4ca931356219d562e Reviewed-by: Christian Ehrlicher Reviewed-by: Jan Arve Sæther --- src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/widgets/doc') diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index c8f374a1b1..35bad6786a 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -993,6 +993,9 @@ \li Supports the \l{box model}. Supports the \l{#default-ps}{:default}, \l{#flat-ps}{:flat}, \l{#checked-ps}{:checked} pseudo states. + Since 5.15, the \l{#icon-prop}{icon} property can be set to + override the button icon. + For QPushButton with a menu, the menu indicator is styled using the \l{#menu-indicator-sub}{::menu-indicator} subcontrol. Appearance of checkable push buttons can be @@ -1945,6 +1948,20 @@ See also \l{#width-prop}{width}. + \row + \li \b{\c icon} \target icon-prop + \li \l{#Url}{Url}+ + \li The icon that is used, for widgets that have an icon. + + The only widget currently supporting this property is QPushButton. + + \note It's the application's responsibilty to assign an icon to a + button (using the QAbstractButton API), and not the style's. So be + careful setting it unless your stylesheet is targeting a specific + application. + + Available since 5.15. + \row \li \b{\c icon-size} \target icon-size-prop \li \l{#Length}{Length} -- cgit v1.2.3 From 54d5ca0c2766e915c960fa437cee6c20a324c1a7 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 16 Nov 2019 16:53:08 +0100 Subject: Doc: improve Using Model Indexes in Model View Programming guide The current example using QFileSystemModel doesn't take into account the asynchronous nature of that model. This puts people on the wrong path on how to use it. This patch improves the snippet as well as the explanation steps. Change-Id: I5c7a3c19aad48847f0b965b5eb69b492d6263f51 Reviewed-by: Paul Wicking --- src/widgets/doc/snippets/simplemodel-use/main.cpp | 7 +++++-- src/widgets/doc/src/model-view-programming.qdoc | 13 +++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/widgets/doc') diff --git a/src/widgets/doc/snippets/simplemodel-use/main.cpp b/src/widgets/doc/snippets/simplemodel-use/main.cpp index 3e106c8eea..940669e101 100644 --- a/src/widgets/doc/snippets/simplemodel-use/main.cpp +++ b/src/widgets/doc/snippets/simplemodel-use/main.cpp @@ -79,8 +79,11 @@ int main(int argc, char *argv[]) //! [0] QFileSystemModel *model = new QFileSystemModel; - QModelIndex parentIndex = model->index(QDir::currentPath()); - int numRows = model->rowCount(parentIndex); + connect(model, &QFileSystemModel::directoryLoaded, [model](const QString &directory) { + QModelIndex parentIndex = model->index(directory); + int numRows = model->rowCount(parentIndex); + }); + model->setRootPath(QDir::currentPath); //! [0] //! [1] diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc index 236582ef3f..ede1ebf932 100644 --- a/src/widgets/doc/src/model-view-programming.qdoc +++ b/src/widgets/doc/src/model-view-programming.qdoc @@ -465,14 +465,19 @@ Although this does not show a normal way of using a model, it demonstrates the conventions used by models when dealing with model indexes. + QFileSystemModel loading is asynchronous to minimize system resource use. + We have to take that into account when dealing with this model. + We construct a file system model in the following way: \snippet simplemodel-use/main.cpp 0 - In this case, we set up a default QFileSystemModel, obtain a parent index - using a specific implementation of \l{QFileSystemModel::}{index()} - provided by that model, and we count the number of rows in the model using - the \l{QFileSystemModel::}{rowCount()} function. + In this case, we start by setting up a default QFileSystemModel. We connect + it to a lambda, in which we will obtain a parent index using a specific + implementation of \l{QFileSystemModel::}{index()} provided by that model. + In the lambda, we count the number of rows in the model using the + \l{QFileSystemModel::}{rowCount()} function. Finally, we set the root path + of the QFileSystemModel so it starts loading data and triggers the lambda. For simplicity, we are only interested in the items in the first column of the model. We examine each row in turn, obtaining a model index for -- cgit v1.2.3