diff options
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | 7 | ||||
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 2 | ||||
-rw-r--r-- | src/widgets/itemviews/qtreewidget.cpp | 5 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 4 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 12 |
5 files changed, 24 insertions, 6 deletions
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index 84233e4b62..c8f374a1b1 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 diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index c2afed775c..b1557e9af4 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -3967,7 +3967,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand(const QM case SingleSelection: // ClearAndSelect on valid index otherwise NoUpdate if (event && event->type() == QEvent::MouseButtonRelease) return QItemSelectionModel::NoUpdate; - if ((keyModifiers & Qt::ControlModifier) && d->selectionModel->isSelected(index)) + if ((keyModifiers & Qt::ControlModifier) && d->selectionModel->isSelected(index) && event->type() != QEvent::MouseMove) return QItemSelectionModel::Deselect | d->selectionBehaviorFlags(); else return QItemSelectionModel::ClearAndSelect | d->selectionBehaviorFlags(); diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index a2d6e7798d..6d0909108b 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -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 QtWidgets module of the Qt Toolkit. @@ -1286,6 +1286,9 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const Sets the background brush of the label in the given \a column to the specified \a brush. + \note If \l{Qt Style Sheets} are used on the same widget as setBackground(), + style sheets will take precedence if the settings conflict. + \sa setForeground() */ diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 74aebd1223..e9968e41b4 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. @@ -8168,6 +8168,8 @@ void QWidgetPrivate::showChildren(bool spontaneous) QList<QObject*> childList = children; for (int i = 0; i < childList.size(); ++i) { QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); + if (widget && widget->windowHandle() && !widget->testAttribute(Qt::WA_WState_ExplicitShowHide)) + widget->setAttribute(Qt::WA_WState_Hidden, false); if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden)) diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 24f8c5ce43..596343c52f 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -72,10 +72,18 @@ public: void setVisible(bool visible) override { Q_Q(QWidgetWindow); - if (QWidget *widget = q->widget()) + if (QWidget *widget = q->widget()) { + // Check if the widget was already hidden, as this indicates it was done + // explicitly and not because the parent window in this case made it hidden. + // In which case do not automatically show the widget when the parent + // window is shown. + const bool wasHidden = widget->testAttribute(Qt::WA_WState_Hidden); QWidgetPrivate::get(widget)->setVisible(visible); - else + if (!wasHidden) + widget->setAttribute(Qt::WA_WState_ExplicitShowHide, false); + } else { QWindowPrivate::setVisible(visible); + } } QWindow *eventReceiver() override { |