summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp10
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp3
-rw-r--r--src/widgets/widgets/qbuttongroup.cpp8
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp11
-rw-r--r--src/widgets/widgets/qcombobox.cpp28
-rw-r--r--src/widgets/widgets/qcombobox.h9
-rw-r--r--src/widgets/widgets/qcombobox_p.h3
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.cpp2
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.h6
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp24
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp2
-rw-r--r--src/widgets/widgets/qdockwidget.cpp39
-rw-r--r--src/widgets/widgets/qdockwidget_p.h29
-rw-r--r--src/widgets/widgets/qfontcombobox.cpp16
-rw-r--r--src/widgets/widgets/qlabel.cpp2
-rw-r--r--src/widgets/widgets/qlineedit.cpp2
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp2
-rw-r--r--src/widgets/widgets/qmainwindow.cpp12
-rw-r--r--src/widgets/widgets/qmainwindow.h6
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp29
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h2
-rw-r--r--src/widgets/widgets/qmdiarea.cpp38
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp14
-rw-r--r--src/widgets/widgets/qmenu.cpp60
-rw-r--r--src/widgets/widgets/qmenu.h4
-rw-r--r--src/widgets/widgets/qmenu_p.h8
-rw-r--r--src/widgets/widgets/qmenubar.cpp4
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp26
-rw-r--r--src/widgets/widgets/qplaintextedit.h4
-rw-r--r--src/widgets/widgets/qpushbutton.cpp4
-rw-r--r--src/widgets/widgets/qscrollarea.cpp2
-rw-r--r--src/widgets/widgets/qspinbox.cpp4
-rw-r--r--src/widgets/widgets/qsplitter.cpp6
-rw-r--r--src/widgets/widgets/qsplitter.h4
-rw-r--r--src/widgets/widgets/qstackedwidget.cpp6
-rw-r--r--src/widgets/widgets/qstatusbar.cpp6
-rw-r--r--src/widgets/widgets/qtabbar.cpp9
-rw-r--r--src/widgets/widgets/qtabwidget.cpp8
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp6
-rw-r--r--src/widgets/widgets/qtextedit.cpp29
-rw-r--r--src/widgets/widgets/qtextedit.h4
-rw-r--r--src/widgets/widgets/qtoolbar.cpp40
-rw-r--r--src/widgets/widgets/qtoolbar.h8
-rw-r--r--src/widgets/widgets/qtoolbararealayout.cpp8
-rw-r--r--src/widgets/widgets/qtoolbararealayout_p.h2
-rw-r--r--src/widgets/widgets/qtoolbarlayout.cpp45
-rw-r--r--src/widgets/widgets/qtoolbox.cpp15
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp5
-rw-r--r--src/widgets/widgets/qwidgetresizehandler_p.h2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp31
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h6
51 files changed, 399 insertions, 254 deletions
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 598d173144..5ea8330db2 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -185,7 +185,7 @@ QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(Qt:
orientation(orientation)
{
setLayout(layout);
- layout->setMargin(0);
+ layout->setContentsMargins(QMargins());
layout->setSpacing(0);
layout->addWidget(scrollBar);
layout->setSizeConstraint(QLayout::SetMaximumSize);
@@ -820,7 +820,7 @@ QWidget *QAbstractScrollArea::cornerWidget() const
All widgets set here will be deleted by the scroll area when it is
destroyed unless you separately reparent the widget after setting
- some other corner widget (or 0).
+ some other corner widget (or \nullptr).
Any \e newly set widget should have no current parent.
@@ -1604,8 +1604,10 @@ QSize QAbstractScrollArea::sizeHint() const
if (!d->sizeHint.isValid() || d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents) {
const int f = 2 * d->frameWidth;
const QSize frame( f, f );
- const QSize scrollbars(d->vbarpolicy == Qt::ScrollBarAlwaysOn ? d->vbar->sizeHint().width() : 0,
- d->hbarpolicy == Qt::ScrollBarAlwaysOn ? d->hbar->sizeHint().height() : 0);
+ const bool vbarHidden = d->vbar->isHidden() || d->vbarpolicy == Qt::ScrollBarAlwaysOff;
+ const bool hbarHidden = d->hbar->isHidden() || d->hbarpolicy == Qt::ScrollBarAlwaysOff;
+ const QSize scrollbars(vbarHidden ? 0 : d->vbar->sizeHint().width(),
+ hbarHidden ? 0 : d->hbar->sizeHint().height());
d->sizeHint = frame + scrollbars + viewportSizeHint();
}
return d->sizeHint;
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 00ac5034e9..f30ea35303 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -212,6 +212,7 @@ void QAbstractSpinBox::setButtonSymbols(ButtonSymbols buttonSymbols)
if (d->buttonSymbols != buttonSymbols) {
d->buttonSymbols = buttonSymbols;
d->updateEditFieldGeometry();
+ updateGeometry();
update();
}
}
@@ -688,7 +689,7 @@ QLineEdit *QAbstractSpinBox::lineEdit() const
\fn void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit)
Sets the line edit of the spinbox to be \a lineEdit instead of the
- current line edit widget. \a lineEdit can not be 0.
+ current line edit widget. \a lineEdit cannot be \nullptr.
QAbstractSpinBox takes ownership of the new lineEdit
diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp
index fa1ccd347f..669faa92c7 100644
--- a/src/widgets/widgets/qbuttongroup.cpp
+++ b/src/widgets/widgets/qbuttongroup.cpp
@@ -291,8 +291,8 @@ QList<QAbstractButton*> QButtonGroup::buttons() const
}
/*!
- Returns the button group's checked button, or 0 if no buttons are
- checked.
+ Returns the button group's checked button, or \nullptr if no
+ buttons are checked.
\sa buttonClicked()
*/
@@ -305,8 +305,8 @@ QAbstractButton *QButtonGroup::checkedButton() const
/*!
\since 4.1
- Returns the button with the specified \a id, or 0 if no such button
- exists.
+ Returns the button with the specified \a id, or \nullptr if no
+ such button exists.
*/
QAbstractButton *QButtonGroup::button(int id) const
{
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index 2ff383d9c7..47c5267c73 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -1178,9 +1178,9 @@ QVariant QCalendarModel::data(const QModelIndex &index, int role) const
}
QTextCharFormat fmt = formatForCell(row, column);
- if (role == Qt::BackgroundColorRole)
+ if (role == Qt::BackgroundRole)
return fmt.background().color();
- if (role == Qt::TextColorRole)
+ if (role == Qt::ForegroundRole)
return fmt.foreground().color();
if (role == Qt::FontRole)
return fmt.font();
@@ -1555,6 +1555,7 @@ void QCalendarView::mouseReleaseEvent(QMouseEvent *event)
}
}
+// ### Qt6: QStyledItemDelegate
class QCalendarDelegate : public QItemDelegate
{
Q_OBJECT
@@ -1777,7 +1778,7 @@ void QCalendarWidgetPrivate::createNavigationBar(QWidget *widget)
spaceHolder = new QSpacerItem(0,0);
QHBoxLayout *headerLayout = new QHBoxLayout;
- headerLayout->setMargin(0);
+ headerLayout->setContentsMargins(QMargins());
headerLayout->setSpacing(0);
headerLayout->addWidget(prevMonth);
headerLayout->insertStretch(headerLayout->count());
@@ -2100,7 +2101,7 @@ QCalendarWidget::QCalendarWidget(QWidget *parent)
setBackgroundRole(QPalette::Window);
QVBoxLayout *layoutV = new QVBoxLayout(this);
- layoutV->setMargin(0);
+ layoutV->setContentsMargins(QMargins());
d->m_model = new QCalendarModel(this);
QTextCharFormat fmt;
fmt.setForeground(QBrush(Qt::red));
@@ -2147,7 +2148,7 @@ QCalendarWidget::QCalendarWidget(QWidget *parent)
connect(d->yearEdit, SIGNAL(editingFinished()),
this, SLOT(_q_yearEditingFinished()));
- layoutV->setMargin(0);
+ layoutV->setContentsMargins(QMargins());
layoutV->setSpacing(0);
layoutV->addWidget(d->navBarBackground);
layoutV->addWidget(d->m_view);
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index bdd2462c92..483cfd8c55 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -167,7 +167,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
break;
}
if (index.data(Qt::BackgroundRole).canConvert<QBrush>()) {
- menuOption.palette.setBrush(QPalette::All, QPalette::Background,
+ menuOption.palette.setBrush(QPalette::All, QPalette::Window,
qvariant_cast<QBrush>(index.data(Qt::BackgroundRole)));
}
menuOption.text = index.model()->data(index, Qt::DisplayRole).toString()
@@ -468,7 +468,7 @@ QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView
// we need a vertical layout
QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
layout->setSpacing(0);
- layout->setMargin(0);
+ layout->setContentsMargins(QMargins());
// set item view
setItemView(itemView);
@@ -891,6 +891,7 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const
currentIndex was reset.
*/
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\fn void QComboBox::currentIndexChanged(const QString &text)
\since 4.1
@@ -899,6 +900,7 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const
changes either through user interaction or programmatically. The
item's \a text is passed.
*/
+#endif
/*!
\fn void QComboBox::currentTextChanged(const QString &text)
@@ -1371,7 +1373,12 @@ void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index)
Q_Q(QComboBox);
const QString text = itemText(index);
emit q->currentIndexChanged(index.row());
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_WARNING_PUSH
+ QT_WARNING_DISABLE_DEPRECATED
emit q->currentIndexChanged(text);
+ QT_WARNING_POP
+#endif
// signal lineEdit.textChanged already connected to signal currentTextChanged, so don't emit double here
if (!lineEdit)
emit q->currentTextChanged(text);
@@ -1479,6 +1486,7 @@ int QComboBox::maxCount() const
}
#if QT_CONFIG(completer)
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\property QComboBox::autoCompletion
@@ -1496,7 +1504,7 @@ int QComboBox::maxCount() const
/*!
\obsolete
- Use setCompleter() instead.
+ Use completer() instead.
*/
bool QComboBox::autoCompletion() const
{
@@ -1572,6 +1580,7 @@ void QComboBox::setAutoCompletionCaseSensitivity(Qt::CaseSensitivity sensitivity
if (d->lineEdit && d->lineEdit->completer())
d->lineEdit->completer()->setCaseSensitivity(sensitivity);
}
+#endif // QT_DEPRECATED_SINCE(5, 13)
#endif // QT_CONFIG(completer)
@@ -1884,8 +1893,8 @@ void QComboBox::setLineEdit(QLineEdit *edit)
}
/*!
- Returns the line edit used to edit items in the combobox, or 0 if there
- is no line edit.
+ Returns the line edit used to edit items in the combobox, or
+ \nullptr if there is no line edit.
Only editable combo boxes have a line edit.
*/
@@ -1937,12 +1946,15 @@ const QValidator *QComboBox::validator() const
performs case insensitive inline completion is automatically created.
\note The completer is removed when the \l editable property becomes \c false.
+ Setting a completer on a QComboBox that is not editable will be ignored.
*/
void QComboBox::setCompleter(QCompleter *c)
{
Q_D(QComboBox);
- if (!d->lineEdit)
+ if (!d->lineEdit) {
+ qWarning("Setting a QCompleter on non-editable QComboBox is not allowed.");
return;
+ }
d->lineEdit->setCompleter(c);
if (c) {
connect(c, SIGNAL(activated(QModelIndex)), this, SLOT(_q_completerActivated(QModelIndex)));
@@ -2013,7 +2025,7 @@ QAbstractItemModel *QComboBox::model() const
}
/*!
- Sets the model to be \a model. \a model must not be 0.
+ Sets the model to be \a model. \a model must not be \nullptr.
If you want to clear the contents of a model, call clear().
\sa clear()
@@ -2599,7 +2611,7 @@ bool QComboBoxPrivate::showNativePopup()
/*!
Displays the list of items in the combobox. If the list is empty
- then the no items will be shown.
+ then no items will be shown.
If you reimplement this function to show a custom pop-up, make
sure you call hidePopup() to reset the internal state.
diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h
index 671c883584..b2fe921bd8 100644
--- a/src/widgets/widgets/qcombobox.h
+++ b/src/widgets/widgets/qcombobox.h
@@ -73,8 +73,10 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
#if QT_CONFIG(completer)
+#if QT_DEPRECATED_SINCE(5, 13)
Q_PROPERTY(bool autoCompletion READ autoCompletion WRITE setAutoCompletion DESIGNABLE false)
Q_PROPERTY(Qt::CaseSensitivity autoCompletionCaseSensitivity READ autoCompletionCaseSensitivity WRITE setAutoCompletionCaseSensitivity DESIGNABLE false)
+#endif
#endif // QT_CONFIG(completer)
Q_PROPERTY(bool duplicatesEnabled READ duplicatesEnabled WRITE setDuplicatesEnabled)
@@ -93,12 +95,17 @@ public:
int maxCount() const;
#if QT_CONFIG(completer)
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X("Use completer() instead.")
bool autoCompletion() const;
+ QT_DEPRECATED_X("Use setCompleter() instead.")
void setAutoCompletion(bool enable);
-
+ QT_DEPRECATED_X("Use completer()->caseSensitivity() instead.")
Qt::CaseSensitivity autoCompletionCaseSensitivity() const;
+ QT_DEPRECATED_X("Use completer()->setCaseSensitivity() instead.")
void setAutoCompletionCaseSensitivity(Qt::CaseSensitivity sensitivity);
#endif
+#endif
bool duplicatesEnabled() const;
void setDuplicatesEnabled(bool enable);
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index 3f75a357e4..71404964da 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -277,7 +277,7 @@ protected:
const QStyleOptionViewItem &option,
const QModelIndex &index) const override {
QStyleOptionMenuItem opt = getStyleOption(option, index);
- painter->fillRect(option.rect, opt.palette.background());
+ painter->fillRect(option.rect, opt.palette.window());
mCombo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, mCombo);
}
QSize sizeHint(const QStyleOptionViewItem &option,
@@ -293,6 +293,7 @@ private:
QComboBox *mCombo;
};
+// ### Qt6: QStyledItemDelegate ?
// Note that this class is intentionally not using QStyledItemDelegate
// Vista does not use the new theme for combo boxes and there might
// be other side effects from using the new class
diff --git a/src/widgets/widgets/qcommandlinkbutton.cpp b/src/widgets/widgets/qcommandlinkbutton.cpp
index 68dfefb3b7..2b9258fd91 100644
--- a/src/widgets/widgets/qcommandlinkbutton.cpp
+++ b/src/widgets/widgets/qcommandlinkbutton.cpp
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
\ingroup basicwidgets
\inmodule QtWidgets
- The command link is a new control that was introduced by Windows Vista. It's
+ The command link is a new control that was introduced by Windows Vista. Its
intended use is similar to that of a radio button in that it is used to choose
between a set of mutually exclusive options. Command link buttons should not
be used by themselves but rather as an alternative to radio buttons in
diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h
index 2d01d63df8..3d2dd5784d 100644
--- a/src/widgets/widgets/qcommandlinkbutton.h
+++ b/src/widgets/widgets/qcommandlinkbutton.h
@@ -66,10 +66,16 @@ public:
QString description() const;
void setDescription(const QString &description);
+ // QTBUG-68722
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
protected:
+#else
+public:
+#endif
QSize sizeHint() const override;
int heightForWidth(int) const override;
QSize minimumSizeHint() const override;
+protected:
bool event(QEvent *e) override;
void paintEvent(QPaintEvent *) override;
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index acab768d75..3e6afdb586 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -2307,13 +2307,31 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event)
style()->drawComplexControl(QStyle::CC_ComboBox, &optCombo, &p, this);
}
+/*
+ Returns the string for AM and PM markers.
+
+ If a translation for "AM" and "PM" is installed, then use that.
+ Otherwise, use the default implementation, which uses the locale.
+*/
QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const
{
+ QString original;
+ QString translated;
if (ap == AmText) {
- return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
+ original = QLatin1String(cs == UpperCase ? "AM" : "am");
+ translated = (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
} else {
- return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
+ original = QLatin1String(cs == UpperCase ? "PM" : "pm");
+ translated = (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
}
+
+ // This logic fails if a translation exists but doesn't change the string,
+ // which we can accept as a corner-case for which a locale-derived answer
+ // will be acceptable.
+ if (original != translated)
+ return translated;
+
+ return QDateTimeParser::getAmPmText(ap, cs);
}
int QDateTimeEditPrivate::absoluteIndex(QDateTimeEdit::Section s, int index) const
@@ -2601,7 +2619,7 @@ void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw)
QVBoxLayout *widgetLayout = qobject_cast<QVBoxLayout*>(layout());
if (!widgetLayout) {
widgetLayout = new QVBoxLayout(this);
- widgetLayout->setMargin(0);
+ widgetLayout->setContentsMargins(QMargins());
widgetLayout->setSpacing(0);
}
delete calendar.data();
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index d93e71e32f..26b86f80be 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -820,7 +820,7 @@ QDialogButtonBox::StandardButtons QDialogButtonBox::standardButtons() const
/*!
Returns the QPushButton corresponding to the standard button \a which,
- or 0 if the standard button doesn't exist in this button box.
+ or \nullptr if the standard button doesn't exist in this button box.
\sa standardButton(), standardButtons(), buttons()
*/
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 6c871aae2c..4041c730b8 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -55,6 +55,7 @@
#include <private/qwidgetresizehandler_p.h>
#include <private/qstylesheetstyle_p.h>
+#include <qpa/qplatformtheme.h>
#include "qdockwidget_p.h"
#include "qmainwindowlayout_p.h"
@@ -66,18 +67,21 @@ extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); /
// qmainwindow.cpp
extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
-static inline QMainWindowLayout *qt_mainwindow_layout_from_dock(const QDockWidget *dock)
+static const QMainWindow *mainwindow_from_dock(const QDockWidget *dock)
{
- const QWidget *p = dock->parentWidget();
- while (p) {
- const QMainWindow *window = qobject_cast<const QMainWindow*>(p);
- if (window)
- return qt_mainwindow_layout(window);
- p = p->parentWidget();
+ for (const QWidget *p = dock->parentWidget(); p; p = p->parentWidget()) {
+ if (const QMainWindow *window = qobject_cast<const QMainWindow*>(p))
+ return window;
}
return nullptr;
}
+static inline QMainWindowLayout *qt_mainwindow_layout_from_dock(const QDockWidget *dock)
+{
+ auto mainWindow = mainwindow_from_dock(dock);
+ return mainWindow ? qt_mainwindow_layout(mainWindow) : nullptr;
+}
+
static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
{ return (priv->features & feature) == feature; }
@@ -838,8 +842,9 @@ void QDockWidgetPrivate::endDrag(bool abort)
q->releaseMouse();
if (state->dragging) {
- QMainWindowLayout *mwLayout = qt_mainwindow_layout_from_dock(q);
- Q_ASSERT(mwLayout != 0);
+ const QMainWindow *mainWindow = mainwindow_from_dock(q);
+ Q_ASSERT(mainWindow != nullptr);
+ QMainWindowLayout *mwLayout = qt_mainwindow_layout(mainWindow);
if (abort || !mwLayout->plug(state->widgetItem)) {
if (hasFeature(this, QDockWidget::DockWidgetFloatable)) {
@@ -860,8 +865,12 @@ void QDockWidgetPrivate::endDrag(bool abort)
} else {
setResizerActive(false);
}
- if (q->isFloating()) // Might not be floating when dragging a QDockWidgetGroupWindow
+ if (q->isFloating()) { // Might not be floating when dragging a QDockWidgetGroupWindow
undockedGeometry = q->geometry();
+#if QT_CONFIG(tabwidget)
+ tabPosition = mwLayout->tabPosition(mainWindow->dockWidgetArea(q));
+#endif
+ }
q->activateWindow();
} else {
// The tab was not plugged back in the QMainWindow but the QDockWidget cannot
@@ -922,7 +931,8 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
initDrag(event->pos(), false);
if (state)
- state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier;
+ state->ctrlDrag = (hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier) ||
+ (!hasFeature(this, QDockWidget::DockWidgetMovable) && q->isFloating());
return true;
}
@@ -1044,7 +1054,8 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
initDrag(event->pos(), true);
if (state == 0)
break;
- state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
+ state->ctrlDrag = (event->modifiers() & Qt::ControlModifier) ||
+ (!hasFeature(this, QDockWidget::DockWidgetMovable) && q->isFloating());
startDrag();
break;
case QEvent::NonClientAreaMouseMove:
@@ -1729,8 +1740,8 @@ void QDockWidget::setTitleBarWidget(QWidget *widget)
/*!
\since 4.3
- Returns the custom title bar widget set on the QDockWidget, or 0 if no
- custom title bar has been set.
+ Returns the custom title bar widget set on the QDockWidget, or
+ \nullptr if no custom title bar has been set.
\sa setTitleBarWidget()
*/
diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h
index 766e4ed161..e224ba7143 100644
--- a/src/widgets/widgets/qdockwidget_p.h
+++ b/src/widgets/widgets/qdockwidget_p.h
@@ -57,6 +57,10 @@
#include "QtWidgets/qboxlayout.h"
#include "QtWidgets/qdockwidget.h"
+#if QT_CONFIG(tabwidget)
+# include "QtWidgets/qtabwidget.h"
+#endif
+
QT_REQUIRE_CONFIG(dockwidget);
QT_BEGIN_NAMESPACE
@@ -81,33 +85,32 @@ class QDockWidgetPrivate : public QWidgetPrivate
};
public:
- inline QDockWidgetPrivate()
- : QWidgetPrivate(), state(0),
- features(QDockWidget::DockWidgetClosable
- | QDockWidget::DockWidgetMovable
- | QDockWidget::DockWidgetFloatable),
- allowedAreas(Qt::AllDockWidgetAreas), resizer(0)
- { }
-
void init();
void _q_toggleView(bool); // private slot
void _q_toggleTopLevel(); // private slot
void updateButtons();
- DragState *state;
- QDockWidget::DockWidgetFeatures features;
- Qt::DockWidgetAreas allowedAreas;
+#if QT_CONFIG(tabwidget)
+ QTabWidget::TabPosition tabPosition = QTabWidget::North;
+#endif
+
+ DragState *state = nullptr;
+
+ QDockWidget::DockWidgetFeatures features = QDockWidget::DockWidgetClosable
+ | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable;
+ Qt::DockWidgetAreas allowedAreas = Qt::AllDockWidgetAreas;
QFont font;
#ifndef QT_NO_ACTION
- QAction *toggleViewAction;
+ QAction *toggleViewAction = nullptr;
#endif
// QMainWindow *findMainWindow(QWidget *widget) const;
QRect undockedGeometry;
QString fixedWindowTitle;
+ QString dockedWindowTitle;
bool mousePressEvent(QMouseEvent *event);
bool mouseDoubleClickEvent(QMouseEvent *event);
@@ -128,7 +131,7 @@ public:
bool isAnimating() const;
private:
- QWidgetResizeHandler *resizer;
+ QWidgetResizeHandler *resizer = nullptr;
};
class Q_WIDGETS_EXPORT QDockWidgetLayout : public QLayout
diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp
index 957a464b71..4a99b0f962 100644
--- a/src/widgets/widgets/qfontcombobox.cpp
+++ b/src/widgets/widgets/qfontcombobox.cpp
@@ -236,9 +236,10 @@ void QFontFamilyDelegate::paint(QPainter *painter,
if (QFontDatabase().isSmoothlyScalable(text)) {
icon = &truetype;
}
- QSize actualSize = icon->actualSize(r.size());
-
- icon->paint(painter, r, Qt::AlignLeft|Qt::AlignVCenter);
+ const QSize actualSize = icon->actualSize(r.size());
+ const QRect iconRect = QStyle::alignedRect(option.direction, option.displayAlignment,
+ actualSize, r);
+ icon->paint(painter, iconRect, Qt::AlignLeft|Qt::AlignVCenter);
if (option.direction == Qt::RightToLeft)
r.setRight(r.right() - actualSize.width() - 4);
else
@@ -247,6 +248,7 @@ void QFontFamilyDelegate::paint(QPainter *painter,
QFont old = painter->font();
painter->setFont(font);
+ const Qt::Alignment textAlign = QStyle::visualAlignment(option.direction, option.displayAlignment);
// If the ascent of the font is larger than the height of the rect,
// we will clip the text, so it's better to align the tight bounding rect in this case
// This is specifically for fonts where the ascent is very large compared to
@@ -254,9 +256,11 @@ void QFontFamilyDelegate::paint(QPainter *painter,
QFontMetricsF fontMetrics(font);
if (fontMetrics.ascent() > r.height()) {
QRectF tbr = fontMetrics.tightBoundingRect(text);
- painter->drawText(r.x(), r.y() + (r.height() + tbr.height()) / 2.0, text);
+ QRect textRect(r);
+ textRect.setHeight(textRect.height() + (r.height() - tbr.height()));
+ painter->drawText(textRect, Qt::AlignBottom|Qt::TextSingleLine|textAlign, text);
} else {
- painter->drawText(r, Qt::AlignVCenter|Qt::AlignLeading|Qt::TextSingleLine, text);
+ painter->drawText(r, Qt::AlignVCenter|Qt::TextSingleLine|textAlign, text);
}
if (writingSystem != QFontDatabase::Any)
@@ -270,7 +274,7 @@ void QFontFamilyDelegate::paint(QPainter *painter,
r.setRight(r.right() - w);
else
r.setLeft(r.left() + w);
- painter->drawText(r, Qt::AlignVCenter|Qt::AlignLeading|Qt::TextSingleLine, sample);
+ painter->drawText(r, Qt::AlignVCenter|Qt::TextSingleLine|textAlign, sample);
}
painter->setFont(old);
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 60f88df9af..a840bf4ee6 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -1098,7 +1098,7 @@ void QLabel::paintEvent(QPaintEvent *)
QImage scaledImage =
d->cachedimage->scaled(scaledSize,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- d->scaledpixmap = new QPixmap(QPixmap::fromImage(scaledImage));
+ d->scaledpixmap = new QPixmap(QPixmap::fromImage(std::move(scaledImage)));
d->scaledpixmap->setDevicePixelRatio(devicePixelRatioF());
}
pix = *d->scaledpixmap;
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 7515f866fe..dee06ba577 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -586,7 +586,7 @@ void QLineEdit::setEchoMode(EchoMode mode)
#ifndef QT_NO_VALIDATOR
/*!
- Returns a pointer to the current input validator, or 0 if no
+ Returns a pointer to the current input validator, or \nullptr if no
validator has been set.
\sa setValidator()
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index 6dcb2dd693..2a5a0c34dc 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -324,7 +324,7 @@ void QLineEditPrivate::drag()
data->setText(control->selectedText());
QDrag *drag = new QDrag(q);
drag->setMimeData(data);
- Qt::DropAction action = drag->start();
+ Qt::DropAction action = drag->exec(Qt::CopyAction);
if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
control->removeSelection();
}
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 411b482c11..9c4c46f2d6 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -596,7 +596,7 @@ QStatusBar *QMainWindow::statusBar() const
/*!
Sets the status bar for the main window to \a statusbar.
- Setting the status bar to 0 will remove it from the main window.
+ Setting the status bar to \nullptr will remove it from the main window.
Note that QMainWindow takes ownership of the \a statusbar pointer
and deletes it at the appropriate time.
@@ -851,7 +851,11 @@ void QMainWindow::removeToolBar(QToolBar *toolbar)
\sa addToolBar(), addToolBarBreak(), Qt::ToolBarArea
*/
-Qt::ToolBarArea QMainWindow::toolBarArea(QToolBar *toolbar) const
+Qt::ToolBarArea QMainWindow::toolBarArea(
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+ const
+#endif
+ QToolBar *toolbar) const
{ return d_func()->layout->toolBarArea(toolbar); }
/*!
@@ -1460,8 +1464,8 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event)
#if QT_CONFIG(menu)
/*!
Returns a popup menu containing checkable entries for the toolbars and
- dock widgets present in the main window. If there are no toolbars and
- dock widgets present, this function returns a null pointer.
+ dock widgets present in the main window. If there are no toolbars and
+ dock widgets present, this function returns \nullptr.
By default, this function is called by the main window when the user
activates a context menu, typically by right-clicking on a toolbar or a dock
diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h
index 8f2a192446..85e3f87d77 100644
--- a/src/widgets/widgets/qmainwindow.h
+++ b/src/widgets/widgets/qmainwindow.h
@@ -158,7 +158,11 @@ public:
bool unifiedTitleAndToolBarOnMac() const;
- Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
+ Qt::ToolBarArea toolBarArea(
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+ const
+#endif
+ QToolBar *toolbar) const;
bool toolBarBreak(QToolBar *toolbar) const;
#endif
#if QT_CONFIG(dockwidget)
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 053bfbf024..f54835f23b 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1388,7 +1388,7 @@ void QMainWindowLayout::insertToolBar(QToolBar *before, QToolBar *toolbar)
invalidate();
}
-Qt::ToolBarArea QMainWindowLayout::toolBarArea(QToolBar *toolbar) const
+Qt::ToolBarArea QMainWindowLayout::toolBarArea(const QToolBar *toolbar) const
{
QInternal::DockPosition pos = layoutState.toolBarAreaLayout.findToolBar(toolbar);
switch (pos) {
@@ -2525,6 +2525,30 @@ void QMainWindowLayout::updateGapIndicator()
#endif // QT_CONFIG(rubberband)
}
+static QTabBar::Shape tabwidgetPositionToTabBarShape(QWidget *w)
+{
+ QTabBar::Shape result = QTabBar::RoundedSouth;
+#if QT_CONFIG(tabwidget)
+ if (qobject_cast<QDockWidget *>(w)) {
+ switch (static_cast<QDockWidgetPrivate *>(qt_widget_private(w))->tabPosition) {
+ case QTabWidget::North:
+ result = QTabBar::RoundedNorth;
+ break;
+ case QTabWidget::South:
+ result = QTabBar::RoundedSouth;
+ break;
+ case QTabWidget::West:
+ result = QTabBar::RoundedWest;
+ break;
+ case QTabWidget::East:
+ result = QTabBar::RoundedEast;
+ break;
+ }
+ }
+#endif // tabwidget
+ return result;
+}
+
void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
{
if (!parentWidget()->isVisible() || parentWidget()->isMinimized()
@@ -2573,8 +2597,9 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow(); // FIXME
floatingTabs->setGeometry(dropTo->geometry());
QDockAreaLayoutInfo *info = floatingTabs->layoutInfo();
+ const QTabBar::Shape shape = tabwidgetPositionToTabBarShape(dropTo);
*info = QDockAreaLayoutInfo(&layoutState.dockAreaLayout.sep, QInternal::LeftDock,
- Qt::Horizontal, QTabBar::RoundedSouth,
+ Qt::Horizontal, shape,
static_cast<QMainWindow *>(parentWidget()));
info->tabbed = true;
QLayout *parentLayout = dropTo->parentWidget()->layout();
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 72cbec2350..a375d856bb 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -475,7 +475,7 @@ public:
void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar, bool needAddChildWidget = true);
void insertToolBar(QToolBar *before, QToolBar *toolbar);
- Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
+ Qt::ToolBarArea toolBarArea(const QToolBar *toolbar) const;
bool toolBarBreak(QToolBar *toolBar) const;
void getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const;
void removeToolBar(QToolBar *toolbar);
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index f32cd26478..8b201dcf9d 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -954,14 +954,6 @@ void QMdiAreaPrivate::rearrange(Rearranger *rearranger)
}
}
- if (active && rearranger->type() == Rearranger::RegularTiler && !tileCalledFromResizeEvent) {
- // Move active window in front if necessary. That's the case if we
- // have any windows with staysOnTopHint set.
- int indexToActive = widgets.indexOf((QWidget *)active);
- if (indexToActive > 0)
- widgets.move(indexToActive, 0);
- }
-
QRect domain = viewport->rect();
if (rearranger->type() == Rearranger::RegularTiler && !widgets.isEmpty())
domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count());
@@ -1296,7 +1288,11 @@ QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, in
minAreaHeight += 2 * frame;
}
const QSize diff = QSize(minAreaWidth, minAreaHeight).expandedTo(q->size()) - q->size();
- topLevel->resize(topLevel->size() + diff);
+ // Only resize topLevel widget if scroll bars are disabled.
+ if (hbarpolicy == Qt::ScrollBarAlwaysOff)
+ topLevel->resize(topLevel->size().width() + diff.width(), topLevel->size().height());
+ if (vbarpolicy == Qt::ScrollBarAlwaysOff)
+ topLevel->resize(topLevel->size().width(), topLevel->size().height() + diff.height());
}
QRect domain = viewport->rect();
@@ -1778,7 +1774,7 @@ QSize QMdiArea::minimumSizeHint() const
}
/*!
- Returns a pointer to the current subwindow, or 0 if there is
+ Returns a pointer to the current subwindow, or \nullptr if there is
no current subwindow.
This function will return the same as activeSubWindow() if
@@ -1790,13 +1786,13 @@ QMdiSubWindow *QMdiArea::currentSubWindow() const
{
Q_D(const QMdiArea);
if (d->childWindows.isEmpty())
- return 0;
+ return nullptr;
if (d->active)
return d->active;
if (d->isActivated && !window()->isMinimized())
- return 0;
+ return nullptr;
Q_ASSERT(d->indicesToActivatedChildren.count() > 0);
int index = d->indicesToActivatedChildren.at(0);
@@ -1808,7 +1804,7 @@ QMdiSubWindow *QMdiArea::currentSubWindow() const
/*!
Returns a pointer to the current active subwindow. If no
- window is currently active, 0 is returned.
+ window is currently active, \nullptr is returned.
Subwindows are treated as top-level windows with respect to
window state, i.e., if a widget outside the MDI area is the active
@@ -1825,7 +1821,7 @@ QMdiSubWindow *QMdiArea::activeSubWindow() const
}
/*!
- Activates the subwindow \a window. If \a window is 0, any
+ Activates the subwindow \a window. If \a window is \nullptr, any
current active window is deactivated.
\sa activeSubWindow()
@@ -1834,7 +1830,7 @@ void QMdiArea::setActiveSubWindow(QMdiSubWindow *window)
{
Q_D(QMdiArea);
if (!window) {
- d->activateWindow(0);
+ d->activateWindow(nullptr);
return;
}
@@ -2002,9 +1998,9 @@ QMdiSubWindow *QMdiArea::addSubWindow(QWidget *widget, Qt::WindowFlags windowFla
Removes \a widget from the MDI area. The \a widget must be
either a QMdiSubWindow or a widget that is the internal widget of
a subwindow. Note \a widget is never actually deleted by QMdiArea.
- If a QMdiSubWindow is passed in its parent is set to 0 and it is
- removed, but if an internal widget is passed in the child widget
- is set to 0 but the QMdiSubWindow is not removed.
+ If a QMdiSubWindow is passed in, its parent is set to \nullptr and it is
+ removed; but if an internal widget is passed in, the child widget
+ is set to \nullptr and the QMdiSubWindow is \e not removed.
\sa addSubWindow()
*/
@@ -2640,7 +2636,11 @@ bool QMdiArea::eventFilter(QObject *object, QEvent *event)
#endif // QT_CONFIG(tabbar)
Q_FALLTHROUGH();
case QEvent::Hide:
- d->isSubWindowsTiled = false;
+ // Do not reset the isSubWindowsTiled flag if the event is a spontaneous system window event.
+ // This ensures that tiling will be performed during the resizeEvent after an application
+ // window minimize (hide) and then restore (show).
+ if (!event->spontaneous())
+ d->isSubWindowsTiled = false;
break;
#if QT_CONFIG(rubberband)
case QEvent::Close:
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index e9511f944f..685c5e159e 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -2268,7 +2268,7 @@ QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags)
setMouseTracking(true);
setLayout(new QVBoxLayout);
setFocusPolicy(Qt::StrongFocus);
- layout()->setMargin(0);
+ layout()->setContentsMargins(QMargins());
d->updateGeometryConstraints();
setAttribute(Qt::WA_Resized, false);
d->titleBarPalette = d->desktopPalette();
@@ -2576,7 +2576,8 @@ void QMdiSubWindow::showSystemMenu()
/*!
\since 4.4
- Returns the area containing this sub-window, or 0 if there is none.
+ Returns the area containing this sub-window, or \nullptr if there
+ is none.
\sa QMdiArea::addSubWindow()
*/
@@ -2590,7 +2591,7 @@ QMdiArea *QMdiSubWindow::mdiArea() const
}
parent = parent->parentWidget();
}
- return 0;
+ return nullptr;
}
/*!
@@ -3347,8 +3348,11 @@ void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent)
}
if ((mouseEvent->buttons() & Qt::LeftButton) || d->isInInteractiveMode) {
- if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled))
- d->setNewGeometry(mapToParent(mouseEvent->pos()));
+ if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled)) {
+ // As setNewGeometry moves the window, it invalidates the pos() value of any mouse move events that are
+ // currently queued in the event loop. Map to parent using globalPos() instead.
+ d->setNewGeometry(parentWidget()->mapFromGlobal(mouseEvent->globalPos()));
+ }
return;
}
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 8dff2ffc34..c61b68e10a 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -1782,21 +1782,6 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
return action;
}
-/*!\fn template<typename PointerToMemberFunction> QAction *QMenu::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)
-
- \since 5.6
-
- \overload
-
- This convenience function creates a new action with the text \a
- text and an optional shortcut \a shortcut. The action's
- \l{QAction::triggered()}{triggered()} signal is connected to the
- \a method of the \a receiver. The function adds the newly created
- action to the menu's list of actions and returns it.
-
- QMenu takes ownership of the returned QAction.
-*/
-
/*!\fn template<typename Functor> QAction *QMenu::addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0)
\since 5.6
@@ -1821,25 +1806,11 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
This convenience function creates a new action with the text \a
text and an optional shortcut \a shortcut. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
- \a functor. The function adds the newly created
- action to the menu's list of actions and returns it.
+ \a functor. The functor can be a pointer to a member function of
+ the \a context object. The newly created action is added to the
+ menu's list of actions and a pointer to it is returned.
- If \a context is destroyed, the functor will not be called.
-
- QMenu takes ownership of the returned QAction.
-*/
-
-/*!\fn template<typename PointerToMemberFunction> QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)
-
- \since 5.6
-
- \overload
-
- This convenience function creates a new action with an \a icon
- and some \a text and an optional shortcut \a shortcut. The action's
- \l{QAction::triggered()}{triggered()} signal is connected to the
- \a method of the \a receiver. The function adds the newly created
- action to the menu's list of actions and returns it.
+ If the \a context object is destroyed, the functor will not be called.
QMenu takes ownership of the returned QAction.
*/
@@ -1868,8 +1839,9 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
This convenience function creates a new action with an \a icon
and some \a text and an optional shortcut \a shortcut. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
- \a functor. The function adds the newly created
- action to the menu's list of actions and returns it.
+ \a functor. The \a functor can be a pointer to a member function
+ of the \a context object. The newly created action is added to the
+ menu's list of actions and a pointer to it is returned.
If \a context is destroyed, the functor will not be called.
@@ -2223,7 +2195,7 @@ void QMenu::setActiveAction(QAction *act)
/*!
- Returns the currently highlighted action, or 0 if no
+ Returns the currently highlighted action, or \nullptr if no
action is currently highlighted.
*/
QAction *QMenu::activeAction() const
@@ -2603,8 +2575,8 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
This is equivalent to \c{exec(pos())}.
This returns the triggered QAction in either the popup menu or one
- of its submenus, or 0 if no item was triggered (normally because
- the user pressed Esc).
+ of its submenus, or \nullptr if no item was triggered (normally
+ because the user pressed Esc).
In most situations you'll want to specify the position yourself,
for example, the current mouse position:
@@ -2630,8 +2602,8 @@ QAction *QMenu::exec()
coordinates into global coordinates, use QWidget::mapToGlobal().
This returns the triggered QAction in either the popup menu or one
- of its submenus, or 0 if no item was triggered (normally because
- the user pressed Esc).
+ of its submenus, or \nullptr if no item was triggered (normally
+ because the user pressed Esc).
Note that all signals are emitted as usual. If you connect a
QAction to a slot and call the menu's exec(), you get the result
@@ -2667,11 +2639,11 @@ QAction *QMenu::exec(const QPoint &p, QAction *action)
QPointer<QObject> guard = this;
(void) eventLoop.exec();
if (guard.isNull())
- return 0;
+ return nullptr;
action = d->syncAction;
- d->syncAction = 0;
- d->eventLoop = 0;
+ d->syncAction = nullptr;
+ d->eventLoop = nullptr;
return action;
}
@@ -2689,7 +2661,7 @@ QAction *QMenu::exec(const QPoint &p, QAction *action)
QGraphicsView).
The function returns the triggered QAction in either the popup
- menu or one of its submenus, or 0 if no item was triggered
+ menu or one of its submenus, or \nullptr if no item was triggered
(normally because the user pressed Esc).
This is equivalent to:
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index 628f818b5e..84ab9e027a 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -82,14 +82,10 @@ public:
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
#ifdef Q_CLANG_QDOC
- template<typename PointerToMemberFunction>
- QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
template<typename Functor>
QAction *addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0);
template<typename Functor>
QAction *addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
- template<typename PointerToMemberFunction>
- QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0);
template<typename Functor>
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index b8976385f4..a72592824b 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -95,6 +95,12 @@ static inline int &rperp(Qt::Orientation o, QPoint &pos)
static inline int &rperp(Qt::Orientation o, QSize &size)
{ return o == Qt::Vertical ? size.rwidth() : size.rheight(); }
+static inline int pick(Qt::Orientation o, const QMargins &m)
+{ return o == Qt::Horizontal ? (m.left() + m.right()) : (m.top() + m.bottom()); }
+
+static inline int perp(Qt::Orientation o, const QMargins &m)
+{ return o == Qt::Vertical ? (m.left() + m.right()) : (m.top() + m.bottom()); }
+
class QTornOffMenu;
class QEventLoop;
@@ -115,7 +121,7 @@ private:
class QMenuSloppyState
{
- Q_DISABLE_COPY(QMenuSloppyState)
+ Q_DISABLE_COPY_MOVE(QMenuSloppyState)
public:
QMenuSloppyState()
: m_enabled(false)
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 33c10f3a9a..9a60f1477d 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -906,8 +906,8 @@ QAction *QMenuBar::insertMenu(QAction *before, QMenu *menu)
}
/*!
- Returns the QAction that is currently highlighted. A null pointer
- will be returned if no action is currently selected.
+ Returns the QAction that is currently highlighted, if any,
+ else \nullptr.
*/
QAction *QMenuBar::activeAction() const
{
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 3b5132a8c8..4a875975a4 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -1622,7 +1622,7 @@ void QPlainTextEdit::timerEvent(QTimerEvent *e)
const QPoint globalPos = QCursor::pos();
pos = d->viewport->mapFromGlobal(globalPos);
QMouseEvent ev(QEvent::MouseMove, pos, d->viewport->mapTo(d->viewport->topLevelWidget(), pos), globalPos,
- Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
+ Qt::LeftButton, Qt::LeftButton, QGuiApplication::keyboardModifiers());
mouseMoveEvent(&ev);
}
int deltaY = qMax(pos.y() - visible.top(), visible.bottom() - pos.y()) - visible.height();
@@ -2052,7 +2052,7 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e)
if (backgroundVisible() && !block.isValid() && offset.y() <= er.bottom()
&& (centerOnScroll() || verticalScrollBar()->maximum() == verticalScrollBar()->minimum())) {
- painter.fillRect(QRect(QPoint((int)er.left(), (int)offset.y()), er.bottomRight()), palette().background());
+ painter.fillRect(QRect(QPoint((int)er.left(), (int)offset.y()), er.bottomRight()), palette().window());
}
}
@@ -2905,6 +2905,7 @@ void QPlainTextEdit::setCenterOnScroll(bool enabled)
if (enabled == d->centerOnScroll)
return;
d->centerOnScroll = enabled;
+ d->_q_adjustScrollbars();
}
@@ -2942,6 +2943,27 @@ bool QPlainTextEdit::find(const QRegExp &exp, QTextDocument::FindFlags options)
#endif
/*!
+ \fn bool QPlainTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
+
+ \since 5.13
+ \overload
+
+ Finds the next occurrence, matching the regular expression, \a exp, using the given
+ \a options. The QTextDocument::FindCaseSensitively option is ignored for this overload,
+ use QRegularExpression::CaseInsensitiveOption instead.
+
+ Returns \c true if a match was found and changes the cursor to select the match;
+ otherwise returns \c false.
+*/
+#if QT_CONFIG(regularexpression)
+bool QPlainTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
+{
+ Q_D(QPlainTextEdit);
+ return d->control->find(exp, options);
+}
+#endif
+
+/*!
\fn void QPlainTextEdit::copyAvailable(bool yes)
This signal is emitted when text is selected or de-selected in the
diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h
index e5ac4c82b8..a5945d649a 100644
--- a/src/widgets/widgets/qplaintextedit.h
+++ b/src/widgets/widgets/qplaintextedit.h
@@ -60,6 +60,7 @@ class QMenu;
class QPlainTextEditPrivate;
class QMimeData;
class QPagedPaintDevice;
+class QRegularExpression;
class Q_WIDGETS_EXPORT QPlainTextEdit : public QAbstractScrollArea
{
@@ -149,6 +150,9 @@ public:
#ifndef QT_NO_REGEXP
bool find(const QRegExp &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#endif
+#if QT_CONFIG(regularexpression)
+ bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
+#endif
inline QString toPlainText() const
{ return document()->toPlainText(); }
diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp
index 8f7271c2dc..b578aa0b18 100644
--- a/src/widgets/widgets/qpushbutton.cpp
+++ b/src/widgets/widgets/qpushbutton.cpp
@@ -545,8 +545,8 @@ void QPushButton::setMenu(QMenu* menu)
}
/*!
- Returns the button's associated popup menu or 0 if no popup menu
- has been set.
+ Returns the button's associated popup menu or \nullptr if no popup
+ menu has been set.
\sa setMenu()
*/
diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp
index 0bfc56f7fa..9994344d79 100644
--- a/src/widgets/widgets/qscrollarea.cpp
+++ b/src/widgets/widgets/qscrollarea.cpp
@@ -217,7 +217,7 @@ void QScrollAreaPrivate::updateScrollBars()
}
/*!
- Returns the scroll area's widget, or 0 if there is none.
+ Returns the scroll area's widget, or \nullptr if there is none.
\sa setWidget()
*/
diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp
index 7624b1ed3c..7d454c6359 100644
--- a/src/widgets/widgets/qspinbox.cpp
+++ b/src/widgets/widgets/qspinbox.cpp
@@ -728,6 +728,10 @@ void QDoubleSpinBox::setPrefix(const QString &prefix)
d->prefix = prefix;
d->updateEdit();
+
+ d->cachedSizeHint = QSize();
+ d->cachedMinimumSizeHint = QSize(); // minimumSizeHint cares about the prefix
+ updateGeometry();
}
/*!
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index 3b516f36b6..de838a8f93 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -1231,7 +1231,7 @@ QSplitterHandle *QSplitter::createHandle()
/*!
Returns the handle to the left of (or above) the item in the
- splitter's layout at the given \a index, or \c nullptr if there is no such item.
+ splitter's layout at the given \a index, or \nullptr if there is no such item.
The handle at index 0 is always hidden.
For right-to-left languages such as Arabic and Hebrew, the layout
@@ -1250,7 +1250,7 @@ QSplitterHandle *QSplitter::handle(int index) const
/*!
Returns the widget at the given \a index in the splitter's layout,
- or \c nullptr if there is no such widget.
+ or \nullptr if there is no such widget.
\sa count(), handle(), indexOf(), insertWidget()
*/
@@ -1783,6 +1783,7 @@ void QSplitter::setStretchFactor(int index, int stretch)
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\relates QSplitter
\obsolete
@@ -1813,6 +1814,7 @@ QTextStream& operator>>(QTextStream& ts, QSplitter& splitter)
splitter.restoreState(std::move(line).toLatin1());
return ts;
}
+#endif
QT_END_NAMESPACE
diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h
index 16fac48d1c..ec980d9ee3 100644
--- a/src/widgets/widgets/qsplitter.h
+++ b/src/widgets/widgets/qsplitter.h
@@ -129,8 +129,12 @@ private:
friend class QSplitterHandle;
};
+#if QT_DEPRECATED_SINCE(5, 13)
+QT_DEPRECATED_X("Use QSplitter::saveState() instead")
Q_WIDGETS_EXPORT QTextStream& operator<<(QTextStream&, const QSplitter&);
+QT_DEPRECATED_X("Use QSplitter::restoreState() instead")
Q_WIDGETS_EXPORT QTextStream& operator>>(QTextStream&, QSplitter&);
+#endif
class QSplitterHandlePrivate;
class Q_WIDGETS_EXPORT QSplitterHandle : public QWidget
diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp
index 2217dab870..f863964c58 100644
--- a/src/widgets/widgets/qstackedwidget.cpp
+++ b/src/widgets/widgets/qstackedwidget.cpp
@@ -220,7 +220,7 @@ int QStackedWidget::currentIndex() const
}
/*!
- Returns the current widget, or 0 if there are no child widgets.
+ Returns the current widget, or \nullptr if there are no child widgets.
\sa currentIndex(), setCurrentWidget()
*/
@@ -260,8 +260,8 @@ int QStackedWidget::indexOf(QWidget *widget) const
}
/*!
- Returns the widget at the given \a index, or 0 if there is no such
- widget.
+ Returns the widget at the given \a index, or \nullptr if there is
+ no such widget.
\sa currentWidget(), indexOf()
*/
diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp
index ef98bb6950..e9044e6cad 100644
--- a/src/widgets/widgets/qstatusbar.cpp
+++ b/src/widgets/widgets/qstatusbar.cpp
@@ -482,14 +482,14 @@ void QStatusBar::reformat()
#if QT_CONFIG(sizegrip)
if (d->resizer) {
d->box = new QHBoxLayout(this);
- d->box->setMargin(0);
+ d->box->setContentsMargins(QMargins());
vbox = new QVBoxLayout;
d->box->addLayout(vbox);
} else
#endif
{
vbox = d->box = new QVBoxLayout(this);
- d->box->setMargin(0);
+ d->box->setContentsMargins(QMargins());
}
vbox->addSpacing(3);
QBoxLayout* l = new QHBoxLayout;
@@ -689,7 +689,7 @@ void QStatusBar::paintEvent(QPaintEvent *event)
}
}
if (haveMessage) {
- p.setPen(palette().foreground().color());
+ p.setPen(palette().windowText().color());
p.drawText(d->messageRect(), Qt::AlignLeading | Qt::AlignVCenter | Qt::TextSingleLine, d->tempItem);
}
}
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 68453e1842..b13f4da9d2 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -2093,7 +2093,6 @@ void QTabBarPrivate::setupMovableTab()
grabImage.setDevicePixelRatio(q->devicePixelRatioF());
grabImage.fill(Qt::transparent);
QStylePainter p(&grabImage, q);
- p.initFrom(q);
QStyleOptionTab tab;
q->initStyleOption(&tab, pressedIndex);
@@ -2567,7 +2566,7 @@ void QTabBar::setChangeCurrentOnDrag(bool change)
The tab bar will take ownership of the widget and so all widgets set here
will be deleted by the tab bar when it is destroyed unless you separately
- reparent the widget after setting some other widget (or 0).
+ reparent the widget after setting some other widget (or \nullptr).
\sa tabsClosable()
*/
@@ -2597,14 +2596,14 @@ void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget)
}
/*!
- Returns the widget set a tab \a index and \a position or 0 if
- one is not set.
+ Returns the widget set a tab \a index and \a position or \nullptr
+ if one is not set.
*/
QWidget *QTabBar::tabButton(int index, ButtonPosition position) const
{
Q_D(const QTabBar);
if (index < 0 || index >= d->tabList.count())
- return 0;
+ return nullptr;
if (position == LeftSide)
return d->tabList.at(index).leftWidget;
else
diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp
index 8a848554e3..547b8a82f9 100644
--- a/src/widgets/widgets/qtabwidget.cpp
+++ b/src/widgets/widgets/qtabwidget.cpp
@@ -579,7 +579,7 @@ void QTabWidget::setTabEnabled(int index, bool enable)
All widgets set here will be deleted by the tab widget when it is
destroyed unless you separately reparent the widget after setting
- some other corner widget (or 0).
+ some other corner widget (or \nullptr).
Note: Corner widgets are designed for \l North and \l South tab positions;
other orientations are known to not work properly.
@@ -605,7 +605,7 @@ void QTabWidget::setCornerWidget(QWidget * widget, Qt::Corner corner)
}
/*!
- Returns the widget shown in the \a corner of the tab widget or 0.
+ Returns the widget shown in the \a corner of the tab widget or \nullptr.
*/
QWidget * QTabWidget::cornerWidget(Qt::Corner corner) const
{
@@ -1146,8 +1146,8 @@ void QTabWidget::keyPressEvent(QKeyEvent *e)
}
/*!
- Returns the tab page at index position \a index or 0 if the \a
- index is out of range.
+ Returns the tab page at index position \a index or \nullptr if the
+ \a index is out of range.
*/
QWidget *QTabWidget::widget(int index) const
{
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index 09541bb53b..bb9a4fed91 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -276,7 +276,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
Q_Q(QTextBrowser);
#ifndef QT_NO_CURSOR
if (q->isVisible())
- QApplication::setOverrideCursor(Qt::WaitCursor);
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
#endif
textOrSourceChanged = true;
@@ -310,7 +310,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
const QStringRef firstTag = txt.leftRef(txt.indexOf(QLatin1Char('>')) + 1);
if (firstTag.startsWith(QLatin1String("<qt")) && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) {
#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
+ QGuiApplication::restoreOverrideCursor();
#endif
#if QT_CONFIG(whatsthis)
QWhatsThis::showText(QCursor::pos(), txt, q);
@@ -355,7 +355,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
#ifndef QT_NO_CURSOR
if (q->isVisible())
- QApplication::restoreOverrideCursor();
+ QGuiApplication::restoreOverrideCursor();
#endif
emit q->sourceChanged(url);
}
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index ab636660d7..0ae63f2dd5 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -105,6 +105,14 @@ public:
else
ed->insertFromMimeData(source);
}
+ QVariant loadResource(int type, const QUrl &name) override {
+ auto *ed = qobject_cast<QTextEdit *>(parent());
+ if (!ed)
+ return QWidgetTextControl::loadResource(type, name);
+
+ QUrl resolvedName = ed->d_func()->resolveUrl(name);
+ return ed->loadResource(type, resolvedName);
+ }
};
QTextEditPrivate::QTextEditPrivate()
@@ -2545,6 +2553,27 @@ bool QTextEdit::find(const QRegExp &exp, QTextDocument::FindFlags options)
#endif
/*!
+ \fn bool QTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
+
+ \since 5.13
+ \overload
+
+ Finds the next occurrence, matching the regular expression, \a exp, using the given
+ \a options. The QTextDocument::FindCaseSensitively option is ignored for this overload,
+ use QRegularExpression::CaseInsensitiveOption instead.
+
+ Returns \c true if a match was found and changes the cursor to select the match;
+ otherwise returns \c false.
+*/
+#if QT_CONFIG(regularexpression)
+bool QTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
+{
+ Q_D(QTextEdit);
+ return d->control->find(exp, options);
+}
+#endif
+
+/*!
\fn void QTextEdit::copyAvailable(bool yes)
This signal is emitted when text is selected or de-selected in the
diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h
index 51d6c2ccba..3aa23aaace 100644
--- a/src/widgets/widgets/qtextedit.h
+++ b/src/widgets/widgets/qtextedit.h
@@ -57,6 +57,7 @@ class QMenu;
class QTextEditPrivate;
class QMimeData;
class QPagedPaintDevice;
+class QRegularExpression;
class Q_WIDGETS_EXPORT QTextEdit : public QAbstractScrollArea
{
@@ -165,6 +166,9 @@ public:
#ifndef QT_NO_REGEXP
bool find(const QRegExp &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#endif
+#if QT_CONFIG(regularexpression)
+ bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
+#endif
QString toPlainText() const;
#ifndef QT_NO_TEXTHTMLPARSER
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index 4af71c126e..bcf5a40ae3 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -799,18 +799,6 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
return action;
}
-/*!\fn template<typename PointerToMemberFunction> QAction *QToolBar::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method)
-
- \since 5.6
-
- \overload
-
- Creates a new action with the given \a text. This action is added to
- the end of the toolbar. The action's
- \l{QAction::triggered()}{triggered()} signal is connected to the
- \a method of the \a receiver.
-*/
-
/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QString &text, Functor functor)
\since 5.6
@@ -829,24 +817,13 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
\overload
- Creates a new action with the given \a text. This action is added to
- the end of the toolbar. The action's
+ Creates a new action with the given \a text. This action is added
+ to the end of the toolbar. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
- \a functor.
-
- If \a context is destroyed, the functor will not be called.
-*/
-
-/*!\fn template<typename PointerToMemberFunction> QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method)
-
- \since 5.6
+ \a functor. The \a functor can be a pointer to a member function
+ in the \a context object.
- \overload
-
- Creates a new action with the given \a icon and \a text. This
- action is added to the end of the toolbar. The action's
- \l{QAction::triggered()}{triggered()} signal is connected to the
- \a method of the \a receiver.
+ If the \a context object is destroyed, the \a functor will not be called.
*/
/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QIcon &icon, const QString &text, Functor functor)
@@ -870,9 +847,10 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
Creates a new action with the given \a icon and \a text. This
action is added to the end of the toolbar. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
- \a functor.
+ \a functor. The \a functor can be a pointer to a member function
+ of the \a context object.
- If \a context is destroyed, the functor will not be called.
+ If the \a context object is destroyed, the \a functor will not be called.
*/
/*!
@@ -1067,7 +1045,7 @@ void QToolBar::paintEvent(QPaintEvent *)
if (d->layout->expanded || d->layout->animating || isWindow()) {
//if the toolbar is expended, we need to fill the background with the window color
//because some styles may expects that.
- p.fillRect(opt.rect, palette().background());
+ p.fillRect(opt.rect, palette().window());
style->drawControl(QStyle::CE_ToolBar, &opt, &p, this);
style->drawPrimitive(QStyle::PE_FrameMenu, &opt, &p, this);
} else {
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index 4ae83190d1..0c434e8d1d 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -99,15 +99,11 @@ public:
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
QAction *addAction(const QIcon &icon, const QString &text,
const QObject *receiver, const char* member);
-#ifdef Q_QDOC
- template<typename PointerToMemberFunction>
- QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method);
+#ifdef Q_CLANG_QDOC
template<typename Functor>
QAction *addAction(const QString &text, Functor functor);
template<typename Functor>
QAction *addAction(const QString &text, const QObject *context, Functor functor);
- template<typename PointerToMemberFunction>
- QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method);
template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, Functor functor);
template<typename Functor>
@@ -149,7 +145,7 @@ public:
connect(result, &QAction::triggered, slot);
return result;
}
-#endif // !Q_QDOC
+#endif // !Q_CLANG_QDOC
QAction *addSeparator();
QAction *insertSeparator(QAction *before);
diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp
index edf497111b..adc329131c 100644
--- a/src/widgets/widgets/qtoolbararealayout.cpp
+++ b/src/widgets/widgets/qtoolbararealayout.cpp
@@ -789,7 +789,7 @@ void QToolBarAreaLayout::deleteAllLayoutItems()
}
}
-QInternal::DockPosition QToolBarAreaLayout::findToolBar(QToolBar *toolBar) const
+QInternal::DockPosition QToolBarAreaLayout::findToolBar(const QToolBar *toolBar) const
{
for (int i = 0; i < QInternal::DockCount; ++i) {
const QToolBarAreaLayoutInfo &dock = docks[i];
@@ -1078,7 +1078,11 @@ bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item)
void QToolBarAreaLayout::remove(const QList<int> &path)
{
Q_ASSERT(path.count() == 3);
- docks[path.at(0)].lines[path.at(1)].toolBarItems.removeAt(path.at(2));
+ QToolBarAreaLayoutInfo &dock = docks[path.at(0)];
+ QToolBarAreaLayoutLine &line = dock.lines[path.at(1)];
+ line.toolBarItems.removeAt(path.at(2));
+ if (line.toolBarItems.isEmpty())
+ dock.lines.removeAt(path.at(1));
}
void QToolBarAreaLayout::remove(QLayoutItem *item)
diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h
index dffbab1f21..17747ef29b 100644
--- a/src/widgets/widgets/qtoolbararealayout_p.h
+++ b/src/widgets/widgets/qtoolbararealayout_p.h
@@ -196,7 +196,7 @@ public:
void insertItem(QInternal::DockPosition pos, QLayoutItem *item);
void insertItem(QToolBar *before, QLayoutItem *item);
- QInternal::DockPosition findToolBar(QToolBar *toolBar) const;
+ QInternal::DockPosition findToolBar(const QToolBar *toolBar) const;
bool toolBarBreak(QToolBar *toolBar) const;
void getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const;
diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp
index f2d329d59d..d50e19a5ed 100644
--- a/src/widgets/widgets/qtoolbarlayout.cpp
+++ b/src/widgets/widgets/qtoolbarlayout.cpp
@@ -119,8 +119,9 @@ void QToolBarLayout::updateMarginAndSpacing()
QStyle *style = tb->style();
QStyleOptionToolBar opt;
tb->initStyleOption(&opt);
- setMargin(style->pixelMetric(QStyle::PM_ToolBarItemMargin, &opt, tb)
- + style->pixelMetric(QStyle::PM_ToolBarFrameWidth, &opt, tb));
+ const int margin = style->pixelMetric(QStyle::PM_ToolBarItemMargin, &opt, tb)
+ + style->pixelMetric(QStyle::PM_ToolBarFrameWidth, &opt, tb);
+ setContentsMargins(margin, margin, margin, margin);
setSpacing(style->pixelMetric(QStyle::PM_ToolBarItemSpacing, &opt, tb));
}
@@ -268,7 +269,7 @@ void QToolBarLayout::updateGeomArray() const
tb->initStyleOption(&opt);
const int handleExtent = movable()
? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0;
- const int margin = this->margin();
+ const QMargins margins = contentsMargins();
const int spacing = this->spacing();
const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
Qt::Orientation o = tb->orientation();
@@ -330,12 +331,12 @@ void QToolBarLayout::updateGeomArray() const
that->empty = count == 0;
rpick(o, that->minSize) += handleExtent;
- that->minSize += QSize(2*margin, 2*margin);
+ that->minSize += QSize(pick(Qt::Horizontal, margins), pick(Qt::Vertical, margins));
if (items.count() > 1)
rpick(o, that->minSize) += spacing + extensionExtent;
rpick(o, that->hint) += handleExtent;
- that->hint += QSize(2*margin, 2*margin);
+ that->hint += QSize(pick(Qt::Horizontal, margins), pick(Qt::Vertical, margins));
that->dirty = false;
}
@@ -384,7 +385,7 @@ void QToolBarLayout::setGeometry(const QRect &rect)
QStyle *style = tb->style();
QStyleOptionToolBar opt;
tb->initStyleOption(&opt);
- const int margin = this->margin();
+ const QMargins margins = contentsMargins();
const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
Qt::Orientation o = tb->orientation();
@@ -403,14 +404,18 @@ void QToolBarLayout::setGeometry(const QRect &rect)
QSize hint = sizeHint();
QPoint pos;
- rpick(o, pos) = pick(o, rect.bottomRight()) - margin - extensionExtent + 2;
+ rpick(o, pos) = pick(o, rect.bottomRight()) -
+ pick(o, QSize(margins.bottom(), margins.right())) - extensionExtent + 2;
if (area == Qt::LeftToolBarArea || area == Qt::TopToolBarArea)
- rperp(o, pos) = perp(o, rect.topLeft()) + margin;
+ rperp(o, pos) = perp(o, rect.topLeft()) +
+ perp(o, QSize(margins.top(), margins.left()));
else
- rperp(o, pos) = perp(o, rect.bottomRight()) - margin - (perp(o, hint) - 2*margin) + 1;
+ rperp(o, pos) = perp(o, rect.bottomRight()) -
+ perp(o, QSize(margins.bottom(), margins.right())) -
+ (perp(o, hint) - perp(o, margins)) + 1;
QSize size;
rpick(o, size) = extensionExtent;
- rperp(o, size) = perp(o, hint) - 2*margin;
+ rperp(o, size) = perp(o, hint) - perp(o, margins);
QRect r(pos, size);
if (o == Qt::Horizontal)
@@ -443,13 +448,13 @@ bool QToolBarLayout::layoutActions(const QSize &size)
tb->initStyleOption(&opt);
const int handleExtent = movable()
? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0;
- const int margin = this->margin();
+ const QMargins margins = contentsMargins();
const int spacing = this->spacing();
const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
Qt::Orientation o = tb->orientation();
bool extensionMenuContainsOnlyWidgetActions = true;
- int space = pick(o, rect.size()) - 2*margin - handleExtent;
+ int space = pick(o, rect.size()) - pick(o, margins) - handleExtent;
if (space <= 0)
return false; // nothing to do.
@@ -458,7 +463,7 @@ bool QToolBarLayout::layoutActions(const QSize &size)
bool ranOutOfSpace = false;
int rows = 0;
- int rowPos = perp(o, rect.topLeft()) + margin;
+ int rowPos = perp(o, rect.topLeft()) + perp(o, QSize(margins.top(), margins.left()));
int i = 0;
while (i < items.count()) {
QVector<QLayoutStruct> a = geomArray;
@@ -521,14 +526,14 @@ bool QToolBarLayout::layoutActions(const QSize &size)
}
QPoint pos;
- rpick(o, pos) = margin + handleExtent + a[j].pos;
+ rpick(o, pos) = pick(o, QSize(margins.top(), margins.left())) + handleExtent + a[j].pos;
rperp(o, pos) = rowPos;
QSize size;
rpick(o, size) = a[j].size;
if (expanded)
rperp(o, size) = rowHeight;
else
- rperp(o, size) = perp(o, rect.size()) - 2*margin;
+ rperp(o, size) = perp(o, rect.size()) - perp(o, QSize(margins.top(), margins.left()));
QRect r(pos, size);
if (o == Qt::Horizontal)
@@ -589,7 +594,7 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const
tb->initStyleOption(&opt);
const int handleExtent = movable()
? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0;
- const int margin = this->margin();
+ const QMargins margins = contentsMargins();
const int spacing = this->spacing();
const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
@@ -609,9 +614,9 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const
if (rows == 1)
++rows; // we want to expand to at least two rows
int space = total_w/rows + spacing + extensionExtent;
- space = qMax(space, min_w - 2*margin - handleExtent);
+ space = qMax(space, min_w - pick(o, margins) - handleExtent);
if (win != 0)
- space = qMin(space, pick(o, win->size()) - 2*margin - handleExtent);
+ space = qMin(space, pick(o, win->size()) - pick(o, margins) - handleExtent);
int w = 0;
int h = 0;
@@ -644,11 +649,11 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const
h += rowHeight + spacing;
}
- w += 2*margin + handleExtent + spacing + extensionExtent;
+ w += pick(Qt::Horizontal, margins) + handleExtent + spacing + extensionExtent;
w = qMax(w, min_w);
if (win != 0)
w = qMin(w, pick(o, win->size()));
- h += 2*margin - spacing; //there is no spacing before the first row
+ h += pick(Qt::Vertical, margins) - spacing; //there is no spacing before the first row
QSize result;
rpick(o, result) = w;
diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp
index 46ade0277c..1c83485bff 100644
--- a/src/widgets/widgets/qtoolbox.cpp
+++ b/src/widgets/widgets/qtoolbox.cpp
@@ -294,7 +294,7 @@ QToolBox::QToolBox(QWidget *parent, Qt::WindowFlags f)
{
Q_D(QToolBox);
d->layout = new QVBoxLayout(this);
- d->layout->setMargin(0);
+ d->layout->setContentsMargins(QMargins());
setBackgroundRole(QPalette::Button);
}
@@ -437,7 +437,7 @@ void QToolBoxPrivate::relayout()
Q_Q(QToolBox);
delete layout;
layout = new QVBoxLayout(q);
- layout->setMargin(0);
+ layout->setContentsMargins(QMargins());
for (QToolBoxPrivate::PageList::ConstIterator i = pageList.constBegin(); i != pageList.constEnd(); ++i) {
layout->addWidget((*i).button);
layout->addWidget((*i).sv);
@@ -504,7 +504,8 @@ int QToolBox::currentIndex() const
}
/*!
- Returns a pointer to the current widget, or 0 if there is no such item.
+ Returns a pointer to the current widget, or \nullptr if there is
+ no such item.
\sa currentIndex(), setCurrentWidget()
*/
@@ -512,7 +513,7 @@ int QToolBox::currentIndex() const
QWidget * QToolBox::currentWidget() const
{
Q_D(const QToolBox);
- return d->currentPage ? d->currentPage->widget : 0;
+ return d->currentPage ? d->currentPage->widget : nullptr;
}
/*!
@@ -530,15 +531,15 @@ void QToolBox::setCurrentWidget(QWidget *widget)
}
/*!
- Returns the widget at position \a index, or 0 if there is no such
- item.
+ Returns the widget at position \a index, or \nullptr if there is
+ no such item.
*/
QWidget *QToolBox::widget(int index) const
{
Q_D(const QToolBox);
if (index < 0 || index >= (int) d->pageList.size())
- return 0;
+ return nullptr;
return d->pageList.at(index).widget;
}
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index 6a24712319..b00b219386 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -669,7 +669,8 @@ void QToolButton::setMenu(QMenu* menu)
}
/*!
- Returns the associated menu, or 0 if no menu has been defined.
+ Returns the associated menu, or \nullptr if no menu has been
+ defined.
\sa setMenu()
*/
@@ -678,7 +679,7 @@ QMenu* QToolButton::menu() const
Q_D(const QToolButton);
if (d->menuAction)
return d->menuAction->menu();
- return 0;
+ return nullptr;
}
/*!
diff --git a/src/widgets/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h
index b87bbd6229..89bc759cc2 100644
--- a/src/widgets/widgets/qwidgetresizehandler_p.h
+++ b/src/widgets/widgets/qwidgetresizehandler_p.h
@@ -100,7 +100,7 @@ protected:
void keyPressEvent(QKeyEvent *e);
private:
- Q_DISABLE_COPY(QWidgetResizeHandler)
+ Q_DISABLE_COPY_MOVE(QWidgetResizeHandler)
enum MousePosition {
Nowhere,
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index ee757bf870..f86a747b0f 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -57,9 +57,6 @@
#include <qtimer.h>
#include "private/qtextdocumentlayout_p.h"
#include "private/qabstracttextdocumentlayout_p.h"
-#if QT_CONFIG(textedit)
-#include "private/qtextedit_p.h"
-#endif
#include "qtextdocument.h"
#include "private/qtextdocument_p.h"
#include "qtextlist.h"
@@ -221,6 +218,14 @@ bool QWidgetTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
else if (e == QKeySequence::SelectPreviousLine) {
op = QTextCursor::Up;
mode = QTextCursor::KeepAnchor;
+ {
+ QTextBlock block = cursor.block();
+ QTextLine line = currentTextLine(cursor);
+ if (!block.previous().isValid()
+ && line.isValid()
+ && line.lineNumber() == 0)
+ op = QTextCursor::Start;
+ }
}
else if (e == QKeySequence::SelectNextLine) {
op = QTextCursor::Down;
@@ -1360,15 +1365,8 @@ process:
QVariant QWidgetTextControl::loadResource(int type, const QUrl &name)
{
-#if !QT_CONFIG(textedit)
Q_UNUSED(type);
Q_UNUSED(name);
-#else
- if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(parent())) {
- QUrl resolvedName = textEdit->d_func()->resolveUrl(name);
- return textEdit->loadResource(type, resolvedName);
- }
-#endif
return QVariant();
}
@@ -3101,6 +3099,19 @@ bool QWidgetTextControl::find(const QRegExp &exp, QTextDocument::FindFlags optio
}
#endif
+#if QT_CONFIG(regularexpression)
+bool QWidgetTextControl::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
+{
+ Q_D(QWidgetTextControl);
+ QTextCursor search = d->doc->find(exp, d->cursor, options);
+ if (search.isNull())
+ return false;
+
+ setTextCursor(search);
+ return true;
+}
+#endif
+
QString QWidgetTextControl::toPlainText() const
{
return document()->toPlainText();
diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h
index 4b2acbd934..202ba36454 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p.h
@@ -80,6 +80,7 @@ class QMenu;
class QWidgetTextControlPrivate;
class QAbstractScrollArea;
class QEvent;
+class QRegularExpression;
class QTimerEvent;
class Q_WIDGETS_EXPORT QWidgetTextControl : public QInputControl
@@ -119,6 +120,9 @@ public:
#ifndef QT_NO_REGEXP
bool find(const QRegExp &exp, QTextDocument::FindFlags options = 0);
#endif
+#if QT_CONFIG(regularexpression)
+ bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = 0);
+#endif
QString toPlainText() const;
#ifndef QT_NO_TEXTHTMLPARSER
@@ -263,7 +267,7 @@ protected:
virtual bool event(QEvent *e) override;
private:
- Q_DISABLE_COPY(QWidgetTextControl)
+ Q_DISABLE_COPY_MOVE(QWidgetTextControl)
Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentCharFormatAndSelection())
Q_PRIVATE_SLOT(d_func(), void _q_emitCursorPosChanged(const QTextCursor &))
Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected())