summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp4
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp3
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h2
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp2
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp2
-rw-r--r--src/widgets/dialogs/qwizard.cpp2
-rw-r--r--src/widgets/doc/snippets/javastyle.cpp2
-rw-r--r--src/widgets/doc/snippets/simplemodel-use/main.cpp7
-rw-r--r--src/widgets/doc/src/model-view-programming.qdoc13
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc24
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h2
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicssceneevent.cpp17
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp9
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp2
-rw-r--r--src/widgets/itemviews/qcolumnviewgrip.cpp2
-rw-r--r--src/widgets/itemviews/qcolumnviewgrip_p.h2
-rw-r--r--src/widgets/itemviews/qdirmodel.cpp2
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp9
-rw-r--r--src/widgets/itemviews/qlistwidget.h6
-rw-r--r--src/widgets/itemviews/qtableview.cpp2
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp8
-rw-r--r--src/widgets/itemviews/qtablewidget.h6
-rw-r--r--src/widgets/itemviews/qtreeview.cpp2
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp13
-rw-r--r--src/widgets/itemviews/qtreewidget.h6
-rw-r--r--src/widgets/kernel/qapplication.cpp2
-rw-r--r--src/widgets/kernel/qboxlayout.cpp2
-rw-r--r--src/widgets/kernel/qformlayout.cpp32
-rw-r--r--src/widgets/kernel/qgesture_p.h3
-rw-r--r--src/widgets/kernel/qlayout.cpp18
-rw-r--r--src/widgets/kernel/qlayout_p.h2
-rw-r--r--src/widgets/kernel/qlayoutengine_p.h6
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp2
-rw-r--r--src/widgets/kernel/qshortcut.cpp76
-rw-r--r--src/widgets/kernel/qshortcut.h58
-rw-r--r--src/widgets/kernel/qstandardgestures.cpp4
-rw-r--r--src/widgets/kernel/qwidget.cpp8
-rw-r--r--src/widgets/kernel/qwidget_p.h2
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp12
-rw-r--r--src/widgets/kernel/qwindowcontainer_p.h2
-rw-r--r--src/widgets/styles/qcommonstyle.cpp2
-rw-r--r--src/widgets/styles/qfusionstyle.cpp2
-rw-r--r--src/widgets/styles/qstyle.cpp2
-rw-r--r--src/widgets/styles/qstyleoption.cpp4
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp63
-rw-r--r--src/widgets/util/qflickgesture.cpp2
-rw-r--r--src/widgets/widgets.pro4
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp4
-rw-r--r--src/widgets/widgets/qabstractslider.cpp4
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp4
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp6
-rw-r--r--src/widgets/widgets/qcombobox.cpp60
-rw-r--r--src/widgets/widgets/qcombobox.h4
-rw-r--r--src/widgets/widgets/qcombobox_p.h1
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp13
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp2
-rw-r--r--src/widgets/widgets/qdockwidget.cpp4
-rw-r--r--src/widgets/widgets/qeffects.cpp2
-rw-r--r--src/widgets/widgets/qfocusframe.cpp2
-rw-r--r--src/widgets/widgets/qgroupbox.cpp2
-rw-r--r--src/widgets/widgets/qkeysequenceedit.cpp2
-rw-r--r--src/widgets/widgets/qlabel.cpp33
-rw-r--r--src/widgets/widgets/qlabel_p.h6
-rw-r--r--src/widgets/widgets/qlineedit.cpp2
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h2
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp2
-rw-r--r--src/widgets/widgets/qmenubar.cpp2
-rw-r--r--src/widgets/widgets/qprogressbar.cpp2
-rw-r--r--src/widgets/widgets/qscrollarea_p.h2
-rw-r--r--src/widgets/widgets/qsizegrip.cpp2
-rw-r--r--src/widgets/widgets/qsplitter.cpp2
-rw-r--r--src/widgets/widgets/qstatusbar.cpp2
-rw-r--r--src/widgets/widgets/qtabbar.cpp2
-rw-r--r--src/widgets/widgets/qtabwidget.cpp2
-rw-r--r--src/widgets/widgets/qtoolbar.cpp2
-rw-r--r--src/widgets/widgets/qtoolbarlayout.cpp4
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h6
81 files changed, 449 insertions, 199 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 65434c96f9..f72bc8df99 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -374,7 +374,7 @@ QFileDialog::QFileDialog(QWidget *parent,
const QString &caption,
const QString &directory,
const QString &filter)
- : QDialog(*new QFileDialogPrivate, parent, 0)
+ : QDialog(*new QFileDialogPrivate, parent, { })
{
Q_D(QFileDialog);
d->init(QUrl::fromLocalFile(directory), filter, caption);
@@ -384,7 +384,7 @@ QFileDialog::QFileDialog(QWidget *parent,
\internal
*/
QFileDialog::QFileDialog(const QFileDialogArgs &args)
- : QDialog(*new QFileDialogPrivate, args.parent, 0)
+ : QDialog(*new QFileDialogPrivate, args.parent, { })
{
Q_D(QFileDialog);
d->init(args.directory, args.filter, args.caption);
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index a04189513a..79a7c23e0d 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -2077,7 +2077,8 @@ void QFileSystemModelPrivate::init()
#endif // filesystemwatcher
q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection);
- roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
+ roleNames.insert(QFileSystemModel::FileIconRole,
+ QByteArrayLiteral("fileIcon")); // == Qt::decoration
roleNames.insert(QFileSystemModel::FilePathRole, QByteArrayLiteral("filePath"));
roleNames.insert(QFileSystemModel::FileNameRole, QByteArrayLiteral("fileName"));
roleNames.insert(QFileSystemModel::FilePermissions, QByteArrayLiteral("filePermissions"));
diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index 844e417e2d..ad98b9ef44 100644
--- a/src/widgets/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
@@ -116,7 +116,7 @@ public:
inline qint64 size() const { if (info && !info->isDir()) return info->size(); return 0; }
inline QString type() const { if (info) return info->displayType; return QLatin1String(""); }
inline QDateTime lastModified() const { if (info) return info->lastModified(); return QDateTime(); }
- inline QFile::Permissions permissions() const { if (info) return info->permissions(); return nullptr; }
+ inline QFile::Permissions permissions() const { if (info) return info->permissions(); return { }; }
inline bool isReadable() const { return ((permissions() & QFile::ReadUser) != 0); }
inline bool isWritable() const { return ((permissions() & QFile::WriteUser) != 0); }
inline bool isExecutable() const { return ((permissions() & QFile::ExeUser) != 0); }
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 7e3592e034..3da829d328 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -391,7 +391,7 @@ QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, cons
QFont QFontDialog::getFont(bool *ok, QWidget *parent)
{
QFont initial;
- return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0);
+ return QFontDialogPrivate::getFont(ok, initial, parent, QString(), { });
}
QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent,
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 20f89e132a..5ff8cefec4 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -494,7 +494,7 @@ void QProgressDialogPrivate::adoptChildWidget(QWidget *c)
if (c->parentWidget() == q)
c->hide(); // until after ensureSizeIsAtLeastSizeHint()
else
- c->setParent(q, 0);
+ c->setParent(q, { });
}
ensureSizeIsAtLeastSizeHint();
if (c)
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 0295241a74..7c4a473976 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -3444,7 +3444,7 @@ int QWizard::nextId() const
\sa wizard()
*/
QWizardPage::QWizardPage(QWidget *parent)
- : QWidget(*new QWizardPagePrivate, parent, 0)
+ : QWidget(*new QWizardPagePrivate, parent, { })
{
connect(this, SIGNAL(completeChanged()), this, SLOT(_q_updateCachedCompleteState()));
}
diff --git a/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp
index de3143f753..54a4ade921 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<int>(option->palette.color(QPalette::Mid).rgb());
+ ret = static_cast<int>(option->palette.color(QPalette::Mid).rgba());
break;
}
case QStyle::SH_Menu_Scrollable:
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
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
index 84233e4b62..35bad6786a 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
@@ -988,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
@@ -1941,6 +1949,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}
\li The width and height of the icon in a widget.
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
index 6a8d5c907b..5797d9e539 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
@@ -96,7 +96,7 @@ Qt::Alignment QGraphicsGridLayoutEngine::alignment(QGraphicsLayoutItem *graphics
{
if (QGraphicsGridLayoutEngineItem *gridEngineItem = findLayoutItem(graphicsLayoutItem))
return gridEngineItem->alignment();
- return 0;
+ return { };
}
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
index e98160e40f..2f2c547977 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
@@ -68,7 +68,7 @@ class QGraphicsLayoutPrivate;
class QGraphicsGridLayoutEngineItem : public QGridLayoutItem {
public:
QGraphicsGridLayoutEngineItem(QGraphicsLayoutItem *item, int row, int columns, int rowSpan = 1, int columnSpan = 1,
- Qt::Alignment alignment = nullptr)
+ Qt::Alignment alignment = { })
: QGridLayoutItem(row, columns, rowSpan, columnSpan, alignment), q_layoutItem(item) {}
virtual QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const override
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
index 8964b3b77a..22633df4e3 100644
--- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
@@ -280,7 +280,7 @@ void QGraphicsLinearLayout::insertItem(int index, QGraphicsLayoutItem *item)
Q_ASSERT(item);
d->fixIndex(&index);
d->engine.insertRow(index, d->orientation);
- QGraphicsGridLayoutEngineItem *gridEngineItem = new QGraphicsGridLayoutEngineItem(item, d->gridRow(index), d->gridColumn(index), 1, 1, 0);
+ QGraphicsGridLayoutEngineItem *gridEngineItem = new QGraphicsGridLayoutEngineItem(item, d->gridRow(index), d->gridColumn(index), 1, 1, { });
d->engine.insertItem(gridEngineItem, index);
invalidate();
}
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index 7413a26261..c60dca7a90 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -235,7 +235,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneHoverEvent
mouseEvent.setPos(event->pos());
mouseEvent.setScreenPos(event->screenPos());
mouseEvent.setButton(Qt::NoButton);
- mouseEvent.setButtons(0);
+ mouseEvent.setButtons({ });
mouseEvent.setModifiers(event->modifiers());
sendWidgetMouseEvent(&mouseEvent);
event->setAccepted(mouseEvent.isAccepted());
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp
index 5077a39d67..768dd07d4e 100644
--- a/src/widgets/graphicsview/qgraphicssceneevent.cpp
+++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp
@@ -344,8 +344,7 @@ class QGraphicsSceneMouseEventPrivate : public QGraphicsSceneEventPrivate
Q_DECLARE_PUBLIC(QGraphicsSceneMouseEvent)
public:
inline QGraphicsSceneMouseEventPrivate()
- : button(Qt::NoButton),
- buttons(0), modifiers(0), source(Qt::MouseEventNotSynthesized), flags(0)
+ : button(Qt::NoButton), source(Qt::MouseEventNotSynthesized)
{ }
QPointF pos;
@@ -691,17 +690,15 @@ class QGraphicsSceneWheelEventPrivate : public QGraphicsSceneEventPrivate
{
Q_DECLARE_PUBLIC(QGraphicsSceneWheelEvent)
public:
- inline QGraphicsSceneWheelEventPrivate()
- : buttons(0), modifiers(0), delta(0), orientation(Qt::Horizontal)
- { }
+ inline QGraphicsSceneWheelEventPrivate() = default;
QPointF pos;
QPointF scenePos;
QPoint screenPos;
Qt::MouseButtons buttons;
Qt::KeyboardModifiers modifiers;
- int delta;
- Qt::Orientation orientation;
+ int delta = 0;
+ Qt::Orientation orientation = Qt::Horizontal;
};
/*!
@@ -872,15 +869,13 @@ class QGraphicsSceneContextMenuEventPrivate : public QGraphicsSceneEventPrivate
{
Q_DECLARE_PUBLIC(QGraphicsSceneContextMenuEvent)
public:
- inline QGraphicsSceneContextMenuEventPrivate()
- : modifiers(0), reason(QGraphicsSceneContextMenuEvent::Other)
- { }
+ inline QGraphicsSceneContextMenuEventPrivate() = default;
QPointF pos;
QPointF scenePos;
QPoint screenPos;
Qt::KeyboardModifiers modifiers;
- QGraphicsSceneContextMenuEvent::Reason reason;
+ QGraphicsSceneContextMenuEvent::Reason reason = QGraphicsSceneContextMenuEvent::Other;
};
/*!
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 57be850829..4c270b1af2 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -348,18 +348,17 @@ QGraphicsViewPrivate::QGraphicsViewPrivate()
hasUpdateClip(false),
mousePressButton(Qt::NoButton),
leftIndent(0), topIndent(0),
- lastMouseEvent(QEvent::None, QPointF(), QPointF(), QPointF(), Qt::NoButton, 0, 0),
+ lastMouseEvent(QEvent::None, QPointF(), QPointF(), QPointF(), Qt::NoButton, { }, { }),
alignment(Qt::AlignCenter),
transformationAnchor(QGraphicsView::AnchorViewCenter), resizeAnchor(QGraphicsView::NoAnchor),
viewportUpdateMode(QGraphicsView::MinimalViewportUpdate),
- optimizationFlags(0),
scene(0),
#if QT_CONFIG(rubberband)
rubberBanding(false),
rubberBandSelectionMode(Qt::IntersectsItemShape),
rubberBandSelectionOperation(Qt::ReplaceSelection),
#endif
- handScrollMotions(0), cacheMode(0),
+ handScrollMotions(0),
#ifndef QT_NO_CURSOR
hasStoredOriginalCursor(false),
#endif
@@ -1170,7 +1169,7 @@ void QGraphicsViewPrivate::updateInputMethodSensitivity()
q->viewport()->setAttribute(Qt::WA_InputMethodEnabled, enabled);
if (!enabled) {
- q->setInputMethodHints(0);
+ q->setInputMethodHints({ });
return;
}
@@ -1183,7 +1182,7 @@ void QGraphicsViewPrivate::updateInputMethodSensitivity()
widget = fw;
q->setInputMethodHints(widget->inputMethodHints());
} else {
- q->setInputMethodHints(0);
+ q->setInputMethodHints({ });
}
}
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/qcolumnviewgrip.cpp b/src/widgets/itemviews/qcolumnviewgrip.cpp
index 4a4237805f..00cd7df20a 100644
--- a/src/widgets/itemviews/qcolumnviewgrip.cpp
+++ b/src/widgets/itemviews/qcolumnviewgrip.cpp
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
Use setModel() to set the model.
*/
QColumnViewGrip::QColumnViewGrip(QWidget *parent)
-: QWidget(*new QColumnViewGripPrivate, parent, 0)
+ : QWidget(*new QColumnViewGripPrivate, parent, { })
{
#ifndef QT_NO_CURSOR
setCursor(Qt::SplitHCursor);
diff --git a/src/widgets/itemviews/qcolumnviewgrip_p.h b/src/widgets/itemviews/qcolumnviewgrip_p.h
index 4311edbeb4..13e4c764e8 100644
--- a/src/widgets/itemviews/qcolumnviewgrip_p.h
+++ b/src/widgets/itemviews/qcolumnviewgrip_p.h
@@ -73,7 +73,7 @@ public:
int moveGrip(int offset);
protected:
- QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
+ QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = nullptr, Qt::WindowFlags f = { });
void paintEvent(QPaintEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp
index ba7ee15314..c9e7c7b7a6 100644
--- a/src/widgets/itemviews/qdirmodel.cpp
+++ b/src/widgets/itemviews/qdirmodel.cpp
@@ -1162,7 +1162,7 @@ void QDirModelPrivate::init()
root.parent = 0;
root.info = QFileInfo();
clear(&root);
- roleNames.insertMulti(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
+ roleNames.insert(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
roleNames.insert(QDirModel::FilePathRole, QByteArrayLiteral("filePath"));
roleNames.insert(QDirModel::FileNameRole, QByteArrayLiteral("fileName"));
}
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index c45d41dab5..fefadef1a2 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -987,8 +987,9 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
\fn void QListWidgetItem::setSizeHint(const QSize &size)
\since 4.1
- Sets the size hint for the list item to be \a size. If no size hint is set,
- the item delegate will compute the size hint based on the item data.
+ Sets the size hint for the list item to be \a size.
+ If no size hint is set or \a size is invalid, the item
+ delegate will compute the size hint based on the item data.
*/
/*!
@@ -1119,6 +1120,8 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags)
\since 4.2
Sets the background brush of the list item to the given \a brush.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\sa background(), setForeground()
*/
@@ -1137,6 +1140,8 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags)
\since 4.2
Sets the foreground brush of the list item to the given \a brush.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\sa foreground(), setBackground()
*/
diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h
index c102b144df..1319d658ab 100644
--- a/src/widgets/itemviews/qlistwidget.h
+++ b/src/widgets/itemviews/qlistwidget.h
@@ -127,7 +127,7 @@ public:
inline QBrush background() const
{ return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }
inline void setBackground(const QBrush &brush)
- { setData(Qt::BackgroundRole, brush); }
+ { setData(Qt::BackgroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X ("Use QListWidgetItem::foreground() instead")
@@ -141,7 +141,7 @@ public:
inline QBrush foreground() const
{ return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }
inline void setForeground(const QBrush &brush)
- { setData(Qt::ForegroundRole, brush); }
+ { setData(Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
inline Qt::CheckState checkState() const
{ return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); }
@@ -151,7 +151,7 @@ public:
inline QSize sizeHint() const
{ return qvariant_cast<QSize>(data(Qt::SizeHintRole)); }
inline void setSizeHint(const QSize &size)
- { setData(Qt::SizeHintRole, size); }
+ { setData(Qt::SizeHintRole, size.isValid() ? QVariant(size) : QVariant()); }
virtual QVariant data(int role) const;
virtual void setData(int role, const QVariant &value);
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 11c5be10fd..81fceba8dc 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1431,7 +1431,7 @@ void QTableView::paintEvent(QPaintEvent *event)
const bool showGrid = d->showGrid;
const int gridSize = showGrid ? 1 : 0;
const int gridHint = style()->styleHint(QStyle::SH_Table_GridLineColor, &option, this);
- const QColor gridColor = static_cast<QRgb>(gridHint);
+ const QColor gridColor = QColor::fromRgba(static_cast<QRgb>(gridHint));
const QPen gridPen = QPen(gridColor, 0, d->gridStyle);
const QHeaderView *verticalHeader = d->verticalHeader;
const QHeaderView *horizontalHeader = d->horizontalHeader;
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index b1dbafa997..91860341ee 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -1064,8 +1064,8 @@ QTableWidgetSelectionRange::~QTableWidgetSelectionRange()
\since 4.1
Sets the size hint for the table item to be \a size.
- If no size hint is set, the item delegate will compute the
- size hint based on the item data.
+ If no size hint is set or \a size is invalid, the item
+ delegate will compute the size hint based on the item data.
*/
/*!
@@ -1279,6 +1279,8 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags)
\since 4.2
Sets the item's background brush to the specified \a brush.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\sa setForeground()
*/
@@ -1313,6 +1315,8 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags)
\since 4.2
Sets the item's foreground brush to the specified \a brush.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\sa setBackground()
*/
diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h
index 0d93a0a075..70e2046400 100644
--- a/src/widgets/itemviews/qtablewidget.h
+++ b/src/widgets/itemviews/qtablewidget.h
@@ -146,7 +146,7 @@ public:
inline QBrush background() const
{ return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }
inline void setBackground(const QBrush &brush)
- { setData(Qt::BackgroundRole, brush); }
+ { setData(Qt::BackgroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X ("Use QTableWidgetItem::foreground() instead")
@@ -160,7 +160,7 @@ public:
inline QBrush foreground() const
{ return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }
inline void setForeground(const QBrush &brush)
- { setData(Qt::ForegroundRole, brush); }
+ { setData(Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
inline Qt::CheckState checkState() const
{ return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); }
@@ -170,7 +170,7 @@ public:
inline QSize sizeHint() const
{ return qvariant_cast<QSize>(data(Qt::SizeHintRole)); }
inline void setSizeHint(const QSize &size)
- { setData(Qt::SizeHintRole, size); }
+ { setData(Qt::SizeHintRole, size.isValid() ? QVariant(size) : QVariant()); }
virtual QVariant data(int role) const;
virtual void setData(int role, const QVariant &value);
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 413cc2a9cd..034c1f4b4f 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -233,7 +233,9 @@ void QTreeView::setModel(QAbstractItemModel *model)
d->viewItems.clear();
d->expandedIndexes.clear();
d->hiddenIndexes.clear();
+ d->geometryRecursionBlock = true; // do not update geometries due to signals from the headers
d->header->setModel(model);
+ d->geometryRecursionBlock = false;
QAbstractItemView::setModel(model);
// QAbstractItemView connects to a private slot
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index 68338228b2..8575512078 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.
@@ -1285,6 +1285,11 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const
Sets the background brush of the label in the given \a column to the
specified \a brush.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
+
+ \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()
*/
@@ -1311,6 +1316,8 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const
Returns the brush used to render the foreground (e.g. text) of the
specified \a column.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\sa background()
*/
@@ -1354,8 +1361,8 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const
\since 4.1
Sets the size hint for the tree item in the given \a column to be \a size.
- If no size hint is set, the item delegate will compute the size hint based
- on the item data.
+ If no size hint is set or \a size is invalid, the item
+ delegate will compute the size hint based on the item data.
*/
/*!
diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h
index bed77b336d..b9543fb954 100644
--- a/src/widgets/itemviews/qtreewidget.h
+++ b/src/widgets/itemviews/qtreewidget.h
@@ -146,7 +146,7 @@ public:
inline QBrush background(int column) const
{ return qvariant_cast<QBrush>(data(column, Qt::BackgroundRole)); }
inline void setBackground(int column, const QBrush &brush)
- { setData(column, Qt::BackgroundRole, brush); }
+ { setData(column, Qt::BackgroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X ("Use QTreeWidgetItem::foreground() instead")
@@ -160,7 +160,7 @@ public:
inline QBrush foreground(int column) const
{ return qvariant_cast<QBrush>(data(column, Qt::ForegroundRole)); }
inline void setForeground(int column, const QBrush &brush)
- { setData(column, Qt::ForegroundRole, brush); }
+ { setData(column, Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
inline Qt::CheckState checkState(int column) const
{ return static_cast<Qt::CheckState>(data(column, Qt::CheckStateRole).toInt()); }
@@ -170,7 +170,7 @@ public:
inline QSize sizeHint(int column) const
{ return qvariant_cast<QSize>(data(column, Qt::SizeHintRole)); }
inline void setSizeHint(int column, const QSize &size)
- { setData(column, Qt::SizeHintRole, size); }
+ { setData(column, Qt::SizeHintRole, size.isValid() ? QVariant(size) : QVariant()); }
virtual QVariant data(int column, int role) const;
virtual void setData(int column, int role, const QVariant &value);
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 2d4f114638..6473669c95 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3662,7 +3662,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
// send to all application event filters
if (threadRequiresCoreApplication()
- && receiver->d_func()->threadData->thread.loadAcquire() == mainThread()
+ && receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread()
&& sendThroughApplicationEventFilters(receiver, e)) {
filtered = true;
return filtered;
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index 76d8533271..78d37f381e 100644
--- a/src/widgets/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
@@ -1173,7 +1173,7 @@ void QBoxLayout::setDirection(Direction direction)
if (box->magic) {
QSpacerItem *sp = box->item->spacerItem();
if (sp) {
- if (sp->expandingDirections() == Qt::Orientations(0) /*No Direction*/) {
+ if (sp->expandingDirections() == Qt::Orientations{} /*No Direction*/) {
//spacing or strut
QSize s = sp->sizeHint();
sp->changeSize(s.height(), s.width(),
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index 6f7527c013..c2838083f3 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -199,18 +199,17 @@ public:
ItemMatrix m_matrix;
QList<QFormLayoutItem *> m_things;
- int layoutWidth; // the last width that we called setupVerticalLayoutData on (for vLayouts)
+ int layoutWidth = -1; // the last width that we called setupVerticalLayoutData on (for vLayouts)
- int hfw_width; // the last width we calculated HFW for
- int hfw_height; // what that height was
- int hfw_minheight; // what that minheight was
+ int hfw_width = -1; // the last width we calculated HFW for
+ int hfw_height = -1; // what that height was
- int hfw_sh_height; // the hfw for sh_width
- int hfw_sh_minheight; // the minhfw for sh_width
+ int hfw_sh_height = -1; // the hfw for sh_width
+ int hfw_sh_minheight = -1; // the minhfw for sh_width
- int min_width; // the width that gets turned into minSize (from updateSizes)
- int sh_width; // the width that gets turned into prefSize (from updateSizes)
- int thresh_width; // the width that we start splitting label/field pairs at (from updateSizes)
+ int min_width = -1; // the width that gets turned into minSize (from updateSizes)
+ int sh_width = -1; // the width that gets turned into prefSize (from updateSizes)
+ int thresh_width = QLAYOUTSIZE_MAX; // the width that we start splitting label/field pairs at (from updateSizes)
QSize minSize;
QSize prefSize;
int formMaxWidth;
@@ -222,17 +221,15 @@ public:
QVector<QLayoutStruct> hfwLayouts;
- int hSpacing;
- int vSpacing;
+ int hSpacing = -1;
+ int vSpacing = -1;
QLayoutItem* replaceAt(int index, QLayoutItem*) override;
};
QFormLayoutPrivate::QFormLayoutPrivate()
: fieldGrowthPolicy(DefaultFieldGrowthPolicy),
rowWrapPolicy(DefaultRowWrapPolicy), has_hfw(false), dirty(true), sizesDirty(true),
- expandVertical(0), expandHorizontal(0), labelAlignment(0), formAlignment(0),
- layoutWidth(-1), hfw_width(-1), hfw_sh_height(-1), min_width(-1),
- sh_width(-1), thresh_width(QLAYOUTSIZE_MAX), hSpacing(-1), vSpacing(-1)
+ expandVertical(0), expandHorizontal(0)
{
}
@@ -481,7 +478,6 @@ void QFormLayoutPrivate::recalcHFW(int w)
} else {
hfw_width = w;
hfw_height = qMin(QLAYOUTSIZE_MAX, h);
- hfw_minheight = qMin(QLAYOUTSIZE_MAX, mh);
}
}
@@ -1696,7 +1692,7 @@ Qt::Orientations QFormLayout::expandingDirections() const
QFormLayoutPrivate *e = const_cast<QFormLayoutPrivate *>(d);
e->updateSizes();
- Qt::Orientations o = 0;
+ Qt::Orientations o;
if (e->expandHorizontal)
o = Qt::Horizontal;
if (e->expandVertical)
@@ -2326,7 +2322,7 @@ void QFormLayout::resetRowWrapPolicy()
void QFormLayout::resetFormAlignment()
{
Q_D(QFormLayout);
- d->formAlignment = 0;
+ d->formAlignment = { };
}
/*!
@@ -2336,7 +2332,7 @@ void QFormLayout::resetFormAlignment()
void QFormLayout::resetLabelAlignment()
{
Q_D(QFormLayout);
- d->labelAlignment = 0;
+ d->labelAlignment = { };
}
#if 0
diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h
index cbf8d60892..057302bda1 100644
--- a/src/widgets/kernel/qgesture_p.h
+++ b/src/widgets/kernel/qgesture_p.h
@@ -111,8 +111,7 @@ class QPinchGesturePrivate : public QGesturePrivate
public:
QPinchGesturePrivate()
- : totalChangeFlags(nullptr), changeFlags(nullptr),
- totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1),
+ : totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1),
totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0),
isNewSequence(true)
{
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 3ce81a390b..f0f4fc5505 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -583,18 +583,18 @@ static bool removeWidgetRecursively(QLayoutItem *li, QObject *w)
}
-void QLayoutPrivate::doResize(const QSize &r)
+void QLayoutPrivate::doResize()
{
Q_Q(QLayout);
- int mbh = menuBarHeightForWidth(menubar, r.width());
QWidget *mw = q->parentWidget();
QRect rect = mw->testAttribute(Qt::WA_LayoutOnEntireRect) ? mw->rect() : mw->contentsRect();
+ const int mbh = menuBarHeightForWidth(menubar, rect.width());
const int mbTop = rect.top();
rect.setTop(mbTop + mbh);
q->setGeometry(rect);
#if QT_CONFIG(menubar)
if (menubar)
- menubar->setGeometry(rect.left(), mbTop, r.width(), mbh);
+ menubar->setGeometry(rect.left(), mbTop, rect.width(), mbh);
#endif
}
@@ -613,12 +613,10 @@ void QLayout::widgetEvent(QEvent *e)
switch (e->type()) {
case QEvent::Resize:
- if (d->activated) {
- QResizeEvent *r = (QResizeEvent *)e;
- d->doResize(r->size());
- } else {
+ if (d->activated)
+ d->doResize();
+ else
activate();
- }
break;
case QEvent::ChildRemoved:
{
@@ -1116,7 +1114,7 @@ bool QLayout::activate()
break;
}
- d->doResize(mw->size());
+ d->doResize();
if (md->extra) {
md->extra->explicitMinSize = explMin;
@@ -1339,7 +1337,7 @@ QRect QLayout::alignmentRect(const QRect &r) const
returned by QLayoutItems that have an alignment.
*/
QLayout *that = const_cast<QLayout *>(this);
- that->setAlignment(0);
+ that->setAlignment({ });
QSize ms = that->maximumSize();
that->setAlignment(a);
diff --git a/src/widgets/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h
index 8e1d773355..2b19af48be 100644
--- a/src/widgets/kernel/qlayout_p.h
+++ b/src/widgets/kernel/qlayout_p.h
@@ -73,7 +73,7 @@ public:
QLayoutPrivate();
void getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const;
- void doResize(const QSize &);
+ void doResize();
void reparentChildWidgets(QWidget *mw);
bool checkWidget(QWidget *widget) const;
bool checkLayout(QLayout *otherLayout) const;
diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h
index 948c2424e6..2999bae646 100644
--- a/src/widgets/kernel/qlayoutengine_p.h
+++ b/src/widgets/kernel/qlayoutengine_p.h
@@ -105,9 +105,9 @@ Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidgetItem *i);
Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidget *w);
Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint,
const QSize &minSize, const QSize &maxSize,
- const QSizePolicy &sizePolicy, Qt::Alignment align = nullptr);
-Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = nullptr);
-Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = nullptr);
+ const QSizePolicy &sizePolicy, Qt::Alignment align = { });
+Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = { });
+Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = { });
Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm);
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 0aab0bb06d..ca5a89e4dc 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -591,7 +591,7 @@ Qt::Orientations QSpacerItem::expandingDirections() const
Qt::Orientations QWidgetItem::expandingDirections() const
{
if (isEmpty())
- return Qt::Orientations(0);
+ return {};
Qt::Orientations e = wid->sizePolicy().expandingDirections();
/*
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index 904d765d3c..4a2f8d66c2 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -438,16 +438,86 @@ QShortcut::QShortcut(QWidget *parent)
match the \a key sequence. Depending on the ambiguity of the
event, the shortcut will call the \a member function, or the \a
ambiguousMember function, if the key press was in the shortcut's
- \a context.
+ \a shortcutContext.
*/
QShortcut::QShortcut(const QKeySequence &key, QWidget *parent,
const char *member, const char *ambiguousMember,
- Qt::ShortcutContext context)
- : QGuiShortcut(*new QShortcutPrivate, key, parent, member, ambiguousMember, context)
+ Qt::ShortcutContext shortcutContext)
+ : QGuiShortcut(*new QShortcutPrivate, key, parent, member, ambiguousMember, shortcutContext)
{
}
/*!
+ \fn template<typename Functor>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ Functor functor,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ \since 5.15
+ \overload
+
+ This is a QShortcut convenience constructor which connects the shortcut's
+ \l{QShortcut::activated()}{activated()} signal to the \a functor.
+*/
+/*!
+ \fn template<typename Functor>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context, Functor functor,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ \since 5.15
+ \overload
+
+ This is a QShortcut convenience constructor which connects the shortcut's
+ \l{QShortcut::activated()}{activated()} signal to the \a functor.
+
+ The \a functor can be a pointer to a member function of the \a context object.
+
+ If the \a context object is destroyed, the \a functor will not be called.
+*/
+/*!
+ \fn template<typename Functor, typename FunctorAmbiguous>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context1, Functor functor,
+ FunctorAmbiguous functorAmbiguous,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ \since 5.15
+ \overload
+
+ This is a QShortcut convenience constructor which connects the shortcut's
+ \l{QShortcut::activated()}{activated()} signal to the \a functor and
+ \l{QShortcut::activatedAmbiguously()}{activatedAmbiguously()}
+ signal to the \a FunctorAmbiguous.
+
+ The \a functor and \a FunctorAmbiguous can be a pointer to a member
+ function of the \a context object.
+
+ If the \a context object is destroyed, the \a functor and
+ \a FunctorAmbiguous will not be called.
+*/
+/*!
+ \fn template<typename Functor, typename FunctorAmbiguous>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context1, Functor functor,
+ const QObject *context2, FunctorAmbiguous functorAmbiguous,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ \since 5.15
+ \overload
+
+ This is a QShortcut convenience constructor which connects the shortcut's
+ \l{QShortcut::activated()}{activated()} signal to the \a functor and
+ \l{QShortcut::activatedAmbiguously()}{activatedAmbiguously()}
+ signal to the \a FunctorAmbiguous.
+
+ The \a functor can be a pointer to a member function of the
+ \a context1 object.
+ The \a FunctorAmbiguous can be a pointer to a member function of the
+ \a context2 object.
+
+ If the \a context1 object is destroyed, the \a functor will not be called.
+ If the \a context2 object is destroyed, the \a FunctorAmbiguous
+ will not be called.
+*/
+
+/*!
\property QShortcut::whatsThis
\brief the shortcut's "What's This?" help text
diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h
index 6ac9a37fe3..6c92f87c46 100644
--- a/src/widgets/kernel/qshortcut.h
+++ b/src/widgets/kernel/qshortcut.h
@@ -58,7 +58,63 @@ public:
explicit QShortcut(QWidget *parent);
explicit QShortcut(const QKeySequence& key, QWidget *parent,
const char *member = nullptr, const char *ambiguousMember = nullptr,
- Qt::ShortcutContext context = Qt::WindowShortcut);
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+#ifdef Q_CLANG_QDOC
+ template<typename Functor>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ Functor functor,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ template<typename Functor>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context, Functor functor,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ template<typename Functor, typename FunctorAmbiguous>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context1, Functor functor,
+ FunctorAmbiguous functorAmbiguous,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ template<typename Functor, typename FunctorAmbiguous>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context1, Functor functor,
+ const QObject *context2, FunctorAmbiguous functorAmbiguous,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+#else
+ template<typename Func1>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ Func1 slot1,
+ Qt::ShortcutContext context = Qt::WindowShortcut)
+ : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
+ {
+ connect(this, &QShortcut::activated, std::move(slot1));
+ }
+ template<class Obj1, typename Func1>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const Obj1 *object1, Func1 slot1,
+ Qt::ShortcutContext context = Qt::WindowShortcut)
+ : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
+ {
+ connect(this, &QShortcut::activated, object1, std::move(slot1));
+ }
+ template<class Obj1, typename Func1, typename Func2>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const Obj1 *object1, Func1 slot1, Func2 slot2,
+ Qt::ShortcutContext context = Qt::WindowShortcut)
+ : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
+ {
+ connect(this, &QShortcut::activated, object1, std::move(slot1));
+ connect(this, &QShortcut::activatedAmbiguously, object1, std::move(slot2));
+ }
+ template<class Obj1, typename Func1, class Obj2, typename Func2>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const Obj1 *object1, Func1 slot1,
+ const Obj2 *object2, Func2 slot2,
+ Qt::ShortcutContext context = Qt::WindowShortcut)
+ : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
+ {
+ connect(this, &QShortcut::activated, object1, std::move(slot1));
+ connect(this, &QShortcut::activatedAmbiguously, object2, std::move(slot2));
+ }
+#endif
~QShortcut();
void setWhatsThis(const QString &text);
diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp
index 8a95b12d89..a5c204d59d 100644
--- a/src/widgets/kernel/qstandardgestures.cpp
+++ b/src/widgets/kernel/qstandardgestures.cpp
@@ -183,7 +183,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state,
}
case QEvent::TouchUpdate: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
- d->changeFlags = 0;
+ d->changeFlags = { };
if (ev->touchPoints().size() == 2) {
QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
@@ -256,7 +256,7 @@ void QPinchGestureRecognizer::reset(QGesture *state)
QPinchGesture *pinch = static_cast<QPinchGesture *>(state);
QPinchGesturePrivate *d = pinch->d_func();
- d->totalChangeFlags = d->changeFlags = 0;
+ d->totalChangeFlags = d->changeFlags = { };
d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF();
d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 1;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index efe225a5f5..b2653878c1 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.
@@ -398,7 +398,7 @@ void QWidget::setAutoFillBackground(bool enabled)
If it is \nullptr (the default), the new widget will be a window.
If not, it will be a child of \e parent, and be constrained by
\e parent's geometry (unless you specify Qt::Window as window flag).
- \li \c{Qt::WindowFlags f = 0} (where available) sets the window flags;
+ \li \c{Qt::WindowFlags f = { }} (where available) sets the window flags;
the default is suitable for almost all widgets, but to get, for
example, a window without a window system frame, you must use
special flags.
@@ -1592,7 +1592,7 @@ void QWidgetPrivate::createTLExtra()
x->basew = x->baseh = 0;
x->frameStrut.setCoords(0, 0, 0, 0);
x->normalGeometry = QRect(0,0,-1,-1);
- x->savedFlags = 0;
+ x->savedFlags = { };
x->opacity = 255;
x->posIncludesFrame = 0;
x->sizeAdjusted = false;
@@ -8165,6 +8165,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/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 698928b0b0..62da3fabf4 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -592,7 +592,7 @@ public:
Q_Q(QWidget);
return q->testAttribute(Qt::WA_AlwaysStackOnTop)
? QPlatformTextureList::StacksOnTop
- : QPlatformTextureList::Flags(nullptr);
+ : QPlatformTextureList::Flags();
}
virtual QImage grabFramebuffer() { return QImage(); }
virtual void beginBackingStorePainting() { }
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 {
diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h
index c6de168c10..72474077aa 100644
--- a/src/widgets/kernel/qwindowcontainer_p.h
+++ b/src/widgets/kernel/qwindowcontainer_p.h
@@ -64,7 +64,7 @@ class Q_WIDGETS_EXPORT QWindowContainer : public QWidget
Q_DECLARE_PRIVATE(QWindowContainer)
public:
- explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
+ explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = nullptr, Qt::WindowFlags f = { });
~QWindowContainer();
QWindow *containedWindow() const;
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 271b43fe89..861dd7a54c 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -5143,7 +5143,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
case SH_Table_GridLineColor:
if (opt)
- ret = opt->palette.color(QPalette::Mid).rgb();
+ ret = opt->palette.color(QPalette::Mid).rgba();
else
ret = -1;
break;
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 54bf1d0691..a732d59e48 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -3733,7 +3733,7 @@ int QFusionStyle::styleHint(StyleHint hint, const QStyleOption *option, const QW
return 0;
case SH_Table_GridLineColor:
- return option ? option->palette.window().color().darker(120).rgb() : 0;
+ return option ? option->palette.window().color().darker(120).rgba() : 0;
case SH_MessageBox_TextInteractionFlags:
return Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse;
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index ca81be1b2b..e462d0696b 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -1834,7 +1834,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value SH_LineEdit_PasswordMaskDelay Determines the delay before visible character is masked
with password character, in milliseconds. This enum value was added in Qt 5.4.
- \value SH_Table_GridLineColor The RGB value of the grid for a table.
+ \value SH_Table_GridLineColor The RGBA value of the grid for a table.
\value SH_UnderlineShortcut Whether shortcuts are underlined.
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 564c6cad00..110ebf29c9 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -2909,7 +2909,7 @@ QStyleOptionRubberBand::QStyleOptionRubberBand(int version)
*/
QStyleOptionTitleBar::QStyleOptionTitleBar()
- : QStyleOptionComplex(Version, SO_TitleBar), titleBarState(0), titleBarFlags(0)
+ : QStyleOptionComplex(Version, SO_TitleBar), titleBarState(0)
{
}
@@ -2954,7 +2954,7 @@ QStyleOptionTitleBar::QStyleOptionTitleBar()
\internal
*/
QStyleOptionTitleBar::QStyleOptionTitleBar(int version)
- : QStyleOptionComplex(version, SO_TitleBar), titleBarState(0), titleBarFlags(0)
+ : QStyleOptionComplex(version, SO_TitleBar), titleBarState(0)
{
}
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 3f57992311..24a397a274 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -479,7 +479,7 @@ struct QStyleSheetGeometryData : public QSharedData
struct QStyleSheetPositionData : public QSharedData
{
- QStyleSheetPositionData(int l, int t, int r, int b, Origin o, Qt::Alignment p, QCss::PositionMode m, Qt::Alignment a = 0)
+ QStyleSheetPositionData(int l, int t, int r, int b, Origin o, Qt::Alignment p, QCss::PositionMode m, Qt::Alignment a = { })
: left(l), top(t), bottom(b), right(r), origin(o), position(p), mode(m), textAlignment(a) { }
int left, top, bottom, right;
@@ -534,6 +534,7 @@ public:
const QStyleSheetOutlineData *outline() const { return ou; }
const QStyleSheetGeometryData *geometry() const { return geo; }
const QStyleSheetPositionData *position() const { return p; }
+ const QStyleSheetImageData *icon() const { return iconPtr; }
bool hasModification() const;
@@ -569,6 +570,7 @@ public:
bool hasGeometry() const { return geo != 0; }
bool hasDrawable() const { return !hasNativeBorder() || hasBackground() || hasImage(); }
bool hasImage() const { return img != 0; }
+ bool hasIcon() const { return iconPtr != 0; }
QSize minimumContentsSize() const
{ return geo ? QSize(geo->minWidth, geo->minHeight) : QSize(0, 0); }
@@ -628,6 +630,7 @@ public:
QSharedDataPointer<QStyleSheetGeometryData> geo;
QSharedDataPointer<QStyleSheetPositionData> p;
QSharedDataPointer<QStyleSheetImageData> img;
+ QSharedDataPointer<QStyleSheetImageData> iconPtr;
int clipset;
QPainterPath clipPath;
@@ -919,9 +922,9 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject
int left = 0, top = 0, right = 0, bottom = 0;
Origin origin = Origin_Unknown;
- Qt::Alignment position = 0;
+ Qt::Alignment position;
QCss::PositionMode mode = PositionMode_Unknown;
- Qt::Alignment textAlignment = 0;
+ Qt::Alignment textAlignment;
if (v.extractPosition(&left, &top, &right, &bottom, &origin, &position, &mode, &textAlignment))
p = new QStyleSheetPositionData(left, top, right, bottom, origin, position, mode, textAlignment);
@@ -969,11 +972,16 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject
if (v.extractPalette(&fg, &sfg, &sbg, &abg))
pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg);
- QIcon icon;
+ QIcon imgIcon;
alignment = Qt::AlignCenter;
+ QSize imgSize;
+ if (v.extractImage(&imgIcon, &alignment, &imgSize))
+ img = new QStyleSheetImageData(imgIcon, alignment, imgSize);
+
+ QIcon icon;
QSize size;
- if (v.extractImage(&icon, &alignment, &size))
- img = new QStyleSheetImageData(icon, alignment, size);
+ if (v.extractIcon(&icon, &size))
+ iconPtr = new QStyleSheetImageData(icon, Qt::AlignCenter, size);
int adj = -255;
hasFont = v.extractFont(&font, &adj);
@@ -2223,7 +2231,7 @@ static Qt::Alignment defaultPosition(int pe)
return Qt::AlignRight | Qt::AlignVCenter;
default:
- return 0;
+ return { };
}
}
@@ -3333,7 +3341,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
layout = subControlLayout(QLatin1String("mNX"));
QStyleOptionComplex optCopy(*opt);
- optCopy.subControls = 0;
+ optCopy.subControls = { };
for (int i = 0; i < layout.count(); i++) {
int layoutButton = layout[i].toInt();
if (layoutButton < PseudoElement_MdiCloseButton
@@ -3521,15 +3529,25 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (rule.hasFont)
p->setFont(rule.font.resolve(p->font()));
- if (rule.hasPosition() && rule.position()->textAlignment != 0) {
- Qt::Alignment textAlignment = rule.position()->textAlignment;
- QRect textRect = button->rect;
+ if (rule.hasPosition() || rule.hasIcon()) {
uint tf = Qt::TextShowMnemonic;
+ QRect textRect = button->rect;
+
+ const uint horizontalAlignMask = Qt::AlignHCenter | Qt::AlignLeft | Qt::AlignRight;
const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft;
- tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter;
- if (!styleHint(SH_UnderlineShortcut, button, w))
- tf |= Qt::TextHideMnemonic;
- if (!button->icon.isNull()) {
+
+ if (rule.hasPosition() && rule.position()->textAlignment != 0) {
+ Qt::Alignment textAlignment = rule.position()->textAlignment;
+ tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter;
+ tf |= (textAlignment & horizontalAlignMask) ? (textAlignment & horizontalAlignMask) : Qt::AlignHCenter;
+ if (!styleHint(SH_UnderlineShortcut, button, w))
+ tf |= Qt::TextHideMnemonic;
+ } else {
+ tf |= Qt::AlignVCenter | Qt::AlignHCenter;
+ }
+
+ QIcon icon = rule.hasIcon() ? rule.icon()->icon : button->icon;
+ if (!icon.isNull()) {
//Group both icon and text
QRect iconRect;
QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
@@ -3539,7 +3557,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (button->state & State_On)
state = QIcon::On;
- QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
+ QPixmap pixmap = icon.pixmap(button->iconSize, mode, state);
int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
int labelWidth = pixmapWidth;
@@ -3550,10 +3568,10 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
labelWidth += (textWidth + iconSpacing);
//Determine label alignment:
- if (textAlignment & Qt::AlignLeft) { /*left*/
+ if (tf & Qt::AlignLeft) { /*left*/
iconRect = QRect(textRect.x(), textRect.y() + (textRect.height() - labelHeight) / 2,
pixmapWidth, pixmapHeight);
- } else if (textAlignment & Qt::AlignHCenter) { /* center */
+ } else if (tf & Qt::AlignHCenter) { /* center */
iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
textRect.y() + (textRect.height() - labelHeight) / 2,
pixmapWidth, pixmapHeight);
@@ -3565,7 +3583,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
iconRect = visualRect(button->direction, textRect, iconRect);
- tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead
+ // Left align, adjust the text-rect according to the icon instead
+ tf &= ~horizontalAlignMask;
+ tf |= Qt::AlignLeft;
if (button->direction == Qt::RightToLeft)
textRect.setRight(iconRect.left() - iconSpacing);
@@ -3576,9 +3596,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w),
pixelMetric(PM_ButtonShiftVertical, opt, w));
p->drawPixmap(iconRect, pixmap);
- } else {
- tf |= textAlignment;
}
+
if (button->state & (State_On | State_Sunken))
textRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w),
pixelMetric(PM_ButtonShiftVertical, opt, w));
@@ -4223,7 +4242,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
}
r = subRule.contentsRect(r);
- Qt::Alignment alignment = 0;
+ Qt::Alignment alignment;
if (subRule.hasPosition())
alignment = subRule.position()->textAlignment;
if (alignment == 0)
diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index 14a30ce7cf..03df937938 100644
--- a/src/widgets/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
@@ -610,7 +610,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
}
// depending on the scroller state return the gesture state
- Result result(0);
+ Result result;
bool scrollerIsActive = (scroller->state() == QScroller::Dragging ||
scroller->state() == QScroller::Scrolling);
diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro
index 2aa56ded93..2d5ba05d40 100644
--- a/src/widgets/widgets.pro
+++ b/src/widgets/widgets.pro
@@ -9,8 +9,6 @@ msvc:equals(QT_ARCH, i386): QMAKE_LFLAGS += /BASE:0x65000000
TRACEPOINT_PROVIDER = $$PWD/qtwidgets.tracepoints
CONFIG += qt_tracepoints
-CONFIG += metatypes install_metatypes
-
QMAKE_DOCS = $$PWD/doc/qtwidgets.qdocconf
#platforms
@@ -47,3 +45,5 @@ testcocoon {
MODULE_PLUGIN_TYPES += \
styles
load(qt_module)
+
+CONFIG += metatypes install_metatypes
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index c2f8538ab7..8e6c2cb882 100644
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -467,7 +467,7 @@ void QAbstractButtonPrivate::emitToggled(bool checked)
Constructs an abstract button with a \a parent.
*/
QAbstractButton::QAbstractButton(QWidget *parent)
- : QWidget(*new QAbstractButtonPrivate, parent, 0)
+ : QWidget(*new QAbstractButtonPrivate, parent, { })
{
Q_D(QAbstractButton);
d->init();
@@ -489,7 +489,7 @@ QAbstractButton::QAbstractButton(QWidget *parent)
/*! \internal
*/
QAbstractButton::QAbstractButton(QAbstractButtonPrivate &dd, QWidget *parent)
- : QWidget(dd, parent, 0)
+ : QWidget(dd, parent, { })
{
Q_D(QAbstractButton);
d->init();
diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp
index dc325ab871..a0611565b8 100644
--- a/src/widgets/widgets/qabstractslider.cpp
+++ b/src/widgets/widgets/qabstractslider.cpp
@@ -273,13 +273,13 @@ void QAbstractSliderPrivate::setSteps(int single, int page)
\l value of 0.
*/
QAbstractSlider::QAbstractSlider(QWidget *parent)
- :QWidget(*new QAbstractSliderPrivate, parent, 0)
+ :QWidget(*new QAbstractSliderPrivate, parent, { })
{
}
/*! \internal */
QAbstractSlider::QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent)
- :QWidget(dd, parent, 0)
+ :QWidget(dd, parent, { })
{
}
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index fc19e0793e..b1e1c9bc1b 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -147,7 +147,7 @@ QT_BEGIN_NAMESPACE
*/
QAbstractSpinBox::QAbstractSpinBox(QWidget *parent)
- : QWidget(*new QAbstractSpinBoxPrivate, parent, 0)
+ : QWidget(*new QAbstractSpinBoxPrivate, parent, { })
{
Q_D(QAbstractSpinBox);
d->init();
@@ -157,7 +157,7 @@ QAbstractSpinBox::QAbstractSpinBox(QWidget *parent)
\internal
*/
QAbstractSpinBox::QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent)
- : QWidget(dd, parent, 0)
+ : QWidget(dd, parent, { })
{
Q_D(QAbstractSpinBox);
d->init();
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index 8593001f8b..749ae96df2 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -1207,9 +1207,9 @@ Qt::ItemFlags QCalendarModel::flags(const QModelIndex &index) const
if (!date.isValid())
return QAbstractTableModel::flags(index);
if (date < m_minimumDate)
- return 0;
+ return { };
if (date > m_maximumDate)
- return 0;
+ return { };
return QAbstractTableModel::flags(index);
}
@@ -2135,7 +2135,7 @@ void QCalendarWidgetPrivate::_q_editingFinished()
\sa setCurrentPage()
*/
QCalendarWidget::QCalendarWidget(QWidget *parent)
- : QWidget(*new QCalendarWidgetPrivate, parent, 0)
+ : QWidget(*new QCalendarWidgetPrivate, parent, { })
{
Q_D(QCalendarWidget);
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 9a0e969e1c..03dcde0a58 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -368,6 +368,8 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const
}
if (minimumContentsLength > 0)
sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.horizontalAdvance(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0)));
+ if (!placeholderText.isEmpty())
+ sh.setWidth(qMax(sh.width(), fm.boundingRect(placeholderText).width()));
// height
@@ -929,7 +931,7 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const
model QStandardItemModel.
*/
QComboBox::QComboBox(QWidget *parent)
- : QWidget(*new QComboBoxPrivate(), parent, 0)
+ : QWidget(*new QComboBoxPrivate(), parent, { })
{
Q_D(QComboBox);
d->init();
@@ -939,7 +941,7 @@ QComboBox::QComboBox(QWidget *parent)
\internal
*/
QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent)
- : QWidget(dd, parent, 0)
+ : QWidget(dd, parent, { })
{
Q_D(QComboBox);
d->init();
@@ -1110,8 +1112,9 @@ void QComboBoxPrivate::_q_rowsInserted(const QModelIndex &parent, int start, int
q->updateGeometry();
}
- // set current index if combo was previously empty
- if (start == 0 && (end - start + 1) == q->count() && !currentIndex.isValid()) {
+ // set current index if combo was previously empty and there is no placeholderText
+ if (start == 0 && (end - start + 1) == q->count() && !currentIndex.isValid() &&
+ placeholderText.isEmpty()) {
q->setCurrentIndex(0);
// need to emit changed if model updated index "silently"
} else if (currentIndex.row() != indexBeforeChange) {
@@ -1214,10 +1217,9 @@ void QComboBox::initStyleOption(QStyleOptionComboBox *option) const
} else {
option->activeSubControls = d->hoverControl;
}
- if (d->currentIndex.isValid()) {
- option->currentText = currentText();
+ option->currentText = currentText();
+ if (d->currentIndex.isValid())
option->currentIcon = d->itemIcon(d->currentIndex);
- }
option->iconSize = iconSize();
if (d->container && d->container->isVisible())
option->state |= QStyle::State_On;
@@ -1772,6 +1774,45 @@ void QComboBox::setIconSize(const QSize &size)
}
/*!
+ \property QComboBox::placeholderText
+ \brief Sets a \a placeholderText text shown when no valid index is set
+
+ The \a placeholderText will be shown when an invalid index is set. The
+ text is not accessible in the dropdown list. When this function is called
+ before items are added the placeholder text will be shown, otherwise you
+ have to call setCurrentIndex(-1) programmatically if you want to show the
+ placeholder text.
+ Set an empty placeholder text to reset the setting.
+
+ When the QComboBox is editable, use QLineEdit::setPlaceholderText()
+ instead.
+
+ \since 5.15
+*/
+void QComboBox::setPlaceholderText(const QString &placeholderText)
+{
+ Q_D(QComboBox);
+ if (placeholderText == d->placeholderText)
+ return;
+
+ d->placeholderText = placeholderText;
+ if (currentIndex() == -1) {
+ if (d->placeholderText.isEmpty() && currentIndex() == -1)
+ setCurrentIndex(0);
+ else
+ update();
+ } else {
+ updateGeometry();
+ }
+}
+
+QString QComboBox::placeholderText() const
+{
+ Q_D(const QComboBox);
+ return d->placeholderText;
+}
+
+/*!
\property QComboBox::editable
\brief whether the combo box can be edited by the user
@@ -2249,7 +2290,7 @@ QString QComboBox::currentText() const
else if (d->currentIndex.isValid())
return d->itemText(d->currentIndex);
else
- return QString();
+ return d->placeholderText;
}
/*!
@@ -3079,6 +3120,9 @@ void QComboBox::paintEvent(QPaintEvent *)
initStyleOption(&opt);
painter.drawComplexControl(QStyle::CC_ComboBox, opt);
+ if (currentIndex() < 0)
+ opt.palette.setBrush(QPalette::ButtonText, opt.palette.brush(QPalette::ButtonText).color().lighter());
+
// draw the icon and text
painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
}
diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h
index 286772c091..4f89d7f542 100644
--- a/src/widgets/widgets/qcombobox.h
+++ b/src/widgets/widgets/qcombobox.h
@@ -71,6 +71,7 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget
Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength)
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
+ Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
#if QT_CONFIG(completer)
#if QT_DEPRECATED_SINCE(5, 13)
@@ -148,6 +149,9 @@ public:
QSize iconSize() const;
void setIconSize(const QSize &size);
+ void setPlaceholderText(const QString &placeholderText);
+ QString placeholderText() const;
+
bool isEditable() const;
void setEditable(bool editable);
void setLineEdit(QLineEdit *edit);
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index 5967776a61..00211d70aa 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -417,6 +417,7 @@ public:
int maxVisibleItems;
int maxCount;
int modelColumn;
+ QString placeholderText;
bool inserting;
mutable QSize minimumSizeHint;
mutable QSize sizeHint;
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index f348bbed0e..751e17b717 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -1416,12 +1416,12 @@ QDateTimeEdit::StepEnabled QDateTimeEdit::stepEnabled() const
{
Q_D(const QDateTimeEdit);
if (d->readOnly)
- return StepEnabled(0);
+ return {};
if (d->specialValue()) {
- return (d->minimum == d->maximum ? StepEnabled(0) : StepEnabled(StepUpEnabled));
+ return (d->minimum == d->maximum ? StepEnabled{} : StepEnabled(StepUpEnabled));
}
- QAbstractSpinBox::StepEnabled ret = 0;
+ QAbstractSpinBox::StepEnabled ret = { };
#ifdef QT_KEYPAD_NAVIGATION
if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
@@ -1456,7 +1456,7 @@ QDateTimeEdit::StepEnabled QDateTimeEdit::stepEnabled() const
switch (d->sectionType(d->currentSectionIndex)) {
case QDateTimeParser::NoSection:
case QDateTimeParser::FirstSection:
- case QDateTimeParser::LastSection: return 0;
+ case QDateTimeParser::LastSection: return { };
default: break;
}
if (d->wrapping)
@@ -1659,12 +1659,11 @@ QDateTimeEditPrivate::QDateTimeEditPrivate()
cacheGuard = false;
fixday = true;
type = QVariant::DateTime;
- sections = 0;
+ sections = { };
cachedDay = -1;
currentSectionIndex = FirstSectionIndex;
first.pos = 0;
- sections = 0;
calendarPopup = false;
minimum = QDATETIMEEDIT_COMPAT_DATE_MIN.startOfDay();
maximum = QDATETIMEEDIT_DATE_MAX.endOfDay();
@@ -2256,7 +2255,7 @@ QDateTimeEdit::Section QDateTimeEditPrivate::convertToPublic(QDateTimeParser::Se
QDateTimeEdit::Sections QDateTimeEditPrivate::convertSections(QDateTimeParser::Sections s)
{
- QDateTimeEdit::Sections ret = 0;
+ QDateTimeEdit::Sections ret;
if (s & QDateTimeParser::MSecSection)
ret |= QDateTimeEdit::MSecSection;
if (s & QDateTimeParser::SecondSection)
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 28f6cdc7bd..9096ee82f6 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -482,7 +482,7 @@ QDialogButtonBox::QDialogButtonBox(QWidget *parent)
\sa orientation, addButton()
*/
QDialogButtonBox::QDialogButtonBox(Qt::Orientation orientation, QWidget *parent)
- : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)
+ : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, { })
{
d_func()->initLayout();
}
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 05ec3aface..687ef8ba29 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -238,8 +238,8 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
}
opt.icon = icon();
- opt.subControls = 0;
- opt.activeSubControls = 0;
+ opt.subControls = { };
+ opt.activeSubControls = { };
opt.features = QStyleOptionToolButton::None;
opt.arrowType = Qt::NoArrow;
opt.iconSize = dockButtonIconSize();
diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp
index 7069ef0368..e69366d7c8 100644
--- a/src/widgets/widgets/qeffects.cpp
+++ b/src/widgets/widgets/qeffects.cpp
@@ -65,7 +65,7 @@ class QAlphaWidget: public QWidget, private QEffects
{
Q_OBJECT
public:
- QAlphaWidget(QWidget* w, Qt::WindowFlags f = 0);
+ QAlphaWidget(QWidget* w, Qt::WindowFlags f = { });
~QAlphaWidget();
void run(int time);
diff --git a/src/widgets/widgets/qfocusframe.cpp b/src/widgets/widgets/qfocusframe.cpp
index 0992becdf0..ee24e92c7e 100644
--- a/src/widgets/widgets/qfocusframe.cpp
+++ b/src/widgets/widgets/qfocusframe.cpp
@@ -154,7 +154,7 @@ void QFocusFrame::initStyleOption(QStyleOption *option) const
*/
QFocusFrame::QFocusFrame(QWidget *parent)
- : QWidget(*new QFocusFramePrivate, parent, 0)
+ : QWidget(*new QFocusFramePrivate, parent, { })
{
setAttribute(Qt::WA_TransparentForMouseEvents);
setFocusPolicy(Qt::NoFocus);
diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp
index eec794562a..f7fe072302 100644
--- a/src/widgets/widgets/qgroupbox.cpp
+++ b/src/widgets/widgets/qgroupbox.cpp
@@ -178,7 +178,7 @@ void QGroupBoxPrivate::click()
*/
QGroupBox::QGroupBox(QWidget *parent)
- : QWidget(*new QGroupBoxPrivate, parent, 0)
+ : QWidget(*new QGroupBoxPrivate, parent, { })
{
Q_D(QGroupBox);
d->init();
diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp
index 6f2a6b2d5a..b63b0b4d72 100644
--- a/src/widgets/widgets/qkeysequenceedit.cpp
+++ b/src/widgets/widgets/qkeysequenceedit.cpp
@@ -131,7 +131,7 @@ void QKeySequenceEditPrivate::finishEditing()
Constructs a QKeySequenceEdit widget with the given \a parent.
*/
QKeySequenceEdit::QKeySequenceEdit(QWidget *parent)
- : QKeySequenceEdit(*new QKeySequenceEditPrivate, parent, 0)
+ : QKeySequenceEdit(*new QKeySequenceEditPrivate, parent, { })
{
}
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 943b30bacc..7bd7283adf 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -84,6 +84,7 @@ QLabelPrivate::QLabelPrivate()
shortcutId(0),
#endif
textformat(Qt::AutoText),
+ effectiveTextFormat(Qt::PlainText),
textInteractionFlags(Qt::LinksAccessibleByMouse),
sizePolicy(),
margin(0),
@@ -93,7 +94,6 @@ QLabelPrivate::QLabelPrivate()
scaledcontents(false),
textLayoutDirty(false),
textDirty(false),
- isRichText(false),
isTextLabel(false),
hasShortcut(/*???*/),
#ifndef QT_NO_CURSOR
@@ -293,8 +293,14 @@ void QLabel::setText(const QString &text)
d->text = text;
d->isTextLabel = true;
d->textDirty = true;
- d->isRichText = d->textformat == Qt::RichText
- || (d->textformat == Qt::AutoText && Qt::mightBeRichText(d->text));
+ if (d->textformat == Qt::AutoText) {
+ if (Qt::mightBeRichText(d->text))
+ d->effectiveTextFormat = Qt::RichText;
+ else
+ d->effectiveTextFormat = Qt::PlainText;
+ } else {
+ d->effectiveTextFormat = d->textformat;
+ }
d->control = oldControl;
@@ -305,7 +311,7 @@ void QLabel::setText(const QString &text)
d->control = nullptr;
}
- if (d->isRichText) {
+ if (d->effectiveTextFormat != Qt::PlainText) {
setMouseTracking(true);
} else {
// Note: mouse tracking not disabled intentionally
@@ -1477,14 +1483,19 @@ void QLabelPrivate::ensureTextPopulated() const
if (control) {
QTextDocument *doc = control->document();
if (textDirty) {
-#ifndef QT_NO_TEXTHTMLPARSER
- if (isRichText)
- doc->setHtml(text);
- else
+ if (effectiveTextFormat == Qt::PlainText) {
doc->setPlainText(text);
-#else
- doc->setPlainText(text);
+#if QT_CONFIG(texthtmlparser)
+ } else if (effectiveTextFormat == Qt::RichText) {
+ doc->setHtml(text);
+#endif
+#if QT_CONFIG(textmarkdownreader)
+ } else if (effectiveTextFormat == Qt::MarkdownText) {
+ doc->setMarkdown(text);
#endif
+ } else {
+ doc->setPlainText(text);
+ }
doc->setUndoRedoEnabled(false);
#ifndef QT_NO_SHORTCUT
@@ -1622,7 +1633,7 @@ QMenu *QLabelPrivate::createStandardContextMenu(const QPoint &pos)
{
QString linkToCopy;
QPoint p;
- if (control && isRichText) {
+ if (control && effectiveTextFormat != Qt::PlainText) {
p = layoutPoint(pos);
linkToCopy = control->document()->documentLayout()->anchorAt(p);
}
diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h
index 59188563a9..6b3fbc5f0c 100644
--- a/src/widgets/widgets/qlabel_p.h
+++ b/src/widgets/widgets/qlabel_p.h
@@ -93,8 +93,8 @@ public:
#endif
inline bool needTextControl() const {
return isTextLabel
- && (isRichText
- || (!isRichText && (textInteractionFlags & (Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard))));
+ && (effectiveTextFormat != Qt::PlainText
+ || (textInteractionFlags & (Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard)));
}
void ensureTextPopulated() const;
@@ -134,6 +134,7 @@ public:
int shortcutId;
#endif
Qt::TextFormat textformat;
+ Qt::TextFormat effectiveTextFormat;
Qt::TextInteractionFlags textInteractionFlags;
mutable QSizePolicy sizePolicy;
int margin;
@@ -143,7 +144,6 @@ public:
uint scaledcontents : 1;
mutable uint textLayoutDirty : 1;
mutable uint textDirty : 1;
- mutable uint isRichText : 1;
mutable uint isTextLabel : 1;
mutable uint hasShortcut : 1;
#ifndef QT_NO_CURSOR
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index fe0d87d8c1..37d2211a00 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -276,7 +276,7 @@ QLineEdit::QLineEdit(QWidget* parent)
\sa text(), setMaxLength()
*/
QLineEdit::QLineEdit(const QString& contents, QWidget* parent)
- : QWidget(*new QLineEditPrivate, parent, 0)
+ : QWidget(*new QLineEditPrivate, parent, { })
{
Q_D(QLineEdit);
d->init(contents);
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 967b713096..ebed47da30 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -334,7 +334,7 @@ class QDockWidgetGroupWindow : public QWidget
{
Q_OBJECT
public:
- explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr)
+ explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = { })
: QWidget(parent, f) {}
QDockAreaLayoutInfo *layoutInfo() const;
#if QT_CONFIG(tabbar)
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index f4d3367a95..a2254112c2 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -2214,7 +2214,7 @@ void QMdiSubWindowPrivate::updateInternalWindowTitle()
\sa QMdiArea::addSubWindow()
*/
QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags)
- : QWidget(*new QMdiSubWindowPrivate, parent, 0)
+ : QWidget(*new QMdiSubWindowPrivate, parent, { })
{
Q_D(QMdiSubWindow);
#if QT_CONFIG(menu)
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 7c08376a2b..97816cc889 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -735,7 +735,7 @@ QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) c
/*!
Constructs a menu bar with parent \a parent.
*/
-QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, 0)
+QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, { })
{
Q_D(QMenuBar);
d->init();
diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp
index 56253b8e44..04241fda09 100644
--- a/src/widgets/widgets/qprogressbar.cpp
+++ b/src/widgets/widgets/qprogressbar.cpp
@@ -234,7 +234,7 @@ bool QProgressBarPrivate::repaintRequired() const
*/
QProgressBar::QProgressBar(QWidget *parent)
- : QWidget(*(new QProgressBarPrivate), parent, 0)
+ : QWidget(*(new QProgressBarPrivate), parent, { })
{
d_func()->init();
}
diff --git a/src/widgets/widgets/qscrollarea_p.h b/src/widgets/widgets/qscrollarea_p.h
index 2bdf9ed596..26335285a4 100644
--- a/src/widgets/widgets/qscrollarea_p.h
+++ b/src/widgets/widgets/qscrollarea_p.h
@@ -65,7 +65,7 @@ class QScrollAreaPrivate: public QAbstractScrollAreaPrivate
Q_DECLARE_PUBLIC(QScrollArea)
public:
- QScrollAreaPrivate(): resizable(false), alignment(nullptr){}
+ QScrollAreaPrivate(): resizable(false) {}
void updateScrollBars();
void updateWidgetPosition();
QPointer<QWidget> widget;
diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp
index 835af9c7b8..662d4c9e92 100644
--- a/src/widgets/widgets/qsizegrip.cpp
+++ b/src/widgets/widgets/qsizegrip.cpp
@@ -195,7 +195,7 @@ Qt::Corner QSizeGripPrivate::corner() const
parent.
*/
QSizeGrip::QSizeGrip(QWidget * parent)
- : QWidget(*new QSizeGripPrivate, parent, 0)
+ : QWidget(*new QSizeGripPrivate, parent, { })
{
Q_D(QSizeGrip);
d->init();
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index e7a4889996..1a5fb7f251 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -119,7 +119,7 @@ QSplitterPrivate::~QSplitterPrivate()
\a parent.
*/
QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
- : QWidget(*new QSplitterHandlePrivate, parent, 0)
+ : QWidget(*new QSplitterHandlePrivate, parent, { })
{
Q_D(QSplitterHandle);
d->s = parent;
diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp
index 39f0f11daf..943b576ee3 100644
--- a/src/widgets/widgets/qstatusbar.cpp
+++ b/src/widgets/widgets/qstatusbar.cpp
@@ -226,7 +226,7 @@ QRect QStatusBarPrivate::messageRect() const
\sa setSizeGripEnabled()
*/
QStatusBar::QStatusBar(QWidget * parent)
- : QWidget(*new QStatusBarPrivate, parent, 0)
+ : QWidget(*new QStatusBarPrivate, parent, { })
{
Q_D(QStatusBar);
d->box = 0;
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 7e1794efef..dfe362bdca 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -859,7 +859,7 @@ void QTabBarPrivate::refresh()
Creates a new tab bar with the given \a parent.
*/
QTabBar::QTabBar(QWidget* parent)
- :QWidget(*new QTabBarPrivate, parent, 0)
+ :QWidget(*new QTabBarPrivate, parent, { })
{
Q_D(QTabBar);
d->init();
diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp
index 4d7b39ae01..2b3b8280bb 100644
--- a/src/widgets/widgets/qtabwidget.cpp
+++ b/src/widgets/widgets/qtabwidget.cpp
@@ -359,7 +359,7 @@ void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const
Constructs a tabbed widget with parent \a parent.
*/
QTabWidget::QTabWidget(QWidget *parent)
- : QWidget(*new QTabWidgetPrivate, parent, 0)
+ : QWidget(*new QTabWidgetPrivate, parent, { })
{
Q_D(QTabWidget);
d->init();
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index 4b821f7e41..bed5c3ec3e 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -503,7 +503,7 @@ void QToolBarPrivate::plug(const QRect &r)
Constructs a QToolBar with the given \a parent.
*/
QToolBar::QToolBar(QWidget *parent)
- : QWidget(*new QToolBarPrivate, parent, 0)
+ : QWidget(*new QToolBarPrivate, parent, { })
{
Q_D(QToolBar);
d->init();
diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp
index 5752e0700a..03368fd5c2 100644
--- a/src/widgets/widgets/qtoolbarlayout.cpp
+++ b/src/widgets/widgets/qtoolbarlayout.cpp
@@ -240,9 +240,9 @@ Qt::Orientations QToolBarLayout::expandingDirections() const
updateGeomArray();
QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
if (!tb)
- return Qt::Orientations(0);
+ return {};
Qt::Orientation o = tb->orientation();
- return expanding ? Qt::Orientations(o) : Qt::Orientations(0);
+ return expanding ? Qt::Orientations(o) : Qt::Orientations{};
}
bool QToolBarLayout::movable() const
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index 8ebed25084..a8fffd23dc 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -217,7 +217,7 @@ public:
void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); }
void home(bool mark) { moveCursor(0, mark); }
- void end(bool mark) { moveCursor(text().length(), mark); }
+ void end(bool mark) { moveCursor(m_text.length(), mark); }
int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const;
QRect rectForPos(int pos) const;
diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h
index 59bf5466e6..1f06aa0b97 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p.h
@@ -116,12 +116,12 @@ public:
void setCurrentCharFormat(const QTextCharFormat &format);
QTextCharFormat currentCharFormat() const;
- bool find(const QString &exp, QTextDocument::FindFlags options = nullptr);
+ bool find(const QString &exp, QTextDocument::FindFlags options = { });
#ifndef QT_NO_REGEXP
- bool find(const QRegExp &exp, QTextDocument::FindFlags options = nullptr);
+ bool find(const QRegExp &exp, QTextDocument::FindFlags options = { });
#endif
#if QT_CONFIG(regularexpression)
- bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = nullptr);
+ bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = { });
#endif
QString toPlainText() const;