summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc2
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc4
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp13
-rw-r--r--src/widgets/graphicsview/qgraphicsscene_p.h17
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.cpp9
-rw-r--r--src/widgets/itemviews/qtableview.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp19
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp22
8 files changed, 53 insertions, 35 deletions
diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
index 098eaf4717..b0d042566f 100644
--- a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
+++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
@@ -1107,10 +1107,10 @@ QMenu::indicator:exclusive:checked:selected {
QMenuBar {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 lightgray, stop:1 darkgray);
+ spacing: 3px; /* spacing between menu bar items */
}
QMenuBar::item {
- spacing: 3px; /* spacing between menu bar items */
padding: 1px 4px;
background: transparent;
border-radius: 4px;
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
index 00323eace6..84233e4b62 100644
--- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -549,6 +549,10 @@
If the property references an enum declared with Q_ENUMS, you should
reference its constants by name, i.e., not their numeric value.
+ \note Use the qproperty syntax with care, as it modifies the
+ widget that is being painted. Also, the qproperty syntax is evaluated only
+ once, which is when the widget is polished by the style. This means that any
+ attempt to use them in pseudo-states such as QPushButton:hover, will not work.
*/
/*!
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 1208adfd17..a47d0d879d 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -386,7 +386,15 @@ void QGraphicsScenePrivate::_q_emitUpdated()
// Notify the changes to anybody interested.
QList<QRectF> oldUpdatedRects;
- oldUpdatedRects = updateAll ? (QList<QRectF>() << q->sceneRect()) : updatedRects;
+ if (updateAll) {
+ oldUpdatedRects << q->sceneRect();
+ } else {
+ // Switch to a ranged constructor in Qt 6...
+ oldUpdatedRects.reserve(int(updatedRects.size()));
+ std::copy(updatedRects.cbegin(), updatedRects.cend(),
+ std::back_inserter(oldUpdatedRects));
+ }
+
updateAll = false;
updatedRects.clear();
emit q->changed(oldUpdatedRects);
@@ -3219,8 +3227,7 @@ void QGraphicsScene::update(const QRectF &rect)
view->d_func()->updateRectF(rect);
}
} else {
- if (!d->updatedRects.contains(rect))
- d->updatedRects << rect;
+ d->updatedRects.insert(rect);
}
}
diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h
index 7934359cee..9ecfca8ebf 100644
--- a/src/widgets/graphicsview/qgraphicsscene_p.h
+++ b/src/widgets/graphicsview/qgraphicsscene_p.h
@@ -69,6 +69,9 @@
#include <QtWidgets/qstyle.h>
#include <QtWidgets/qstyleoption.h>
+#include <set>
+#include <tuple>
+
QT_REQUIRE_CONFIG(graphicsview);
QT_BEGIN_NAMESPACE
@@ -122,7 +125,19 @@ public:
QRectF growingItemsBoundingRect;
void _q_emitUpdated();
- QList<QRectF> updatedRects;
+
+ struct UpdatedRectsCmp
+ {
+ bool operator() (const QRectF &a, const QRectF &b) const noexcept
+ {
+ return std::make_tuple(a.y(), a.x(), a.height(), a.width())
+ < std::make_tuple(b.y(), b.x(), b.height(), b.width());
+ }
+ };
+
+ // std::set was used here instead of std::unordered_set due to requiring only a comparator and
+ // showing equivalent performance in empirical measurements within the ranges of interest...
+ std::set<QRectF, UpdatedRectsCmp> updatedRects;
QPainterPath selectionArea;
int selectionChanging;
diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp
index 22067851cb..702e290da3 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.cpp
+++ b/src/widgets/itemviews/qstyleditemdelegate.cpp
@@ -514,15 +514,6 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor,
QStyle *style = widget ? widget->style() : QApplication::style();
QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &opt, widget);
- const int delta = qSmartMinSize(editor).width() - geom.width();
- if (delta > 0) {
- //we need to widen the geometry
- if (editor->layoutDirection() == Qt::RightToLeft)
- geom.adjust(-delta, 0, 0, 0);
- else
- geom.adjust(0, 0, delta, 0);
- }
-
editor->setGeometry(geom);
}
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index c50156bbce..11c5be10fd 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -3331,7 +3331,7 @@ void QTableViewPrivate::selectRow(int row, bool anchor)
if (q->selectionMode() != QTableView::SingleSelection
&& command.testFlag(QItemSelectionModel::Toggle)) {
if (anchor)
- ctrlDragSelectionFlag = verticalHeader->selectionModel()->selectedRows().contains(index)
+ ctrlDragSelectionFlag = verticalHeader->selectionModel()->selectedRows(column).contains(index)
? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
command &= ~QItemSelectionModel::Toggle;
command |= ctrlDragSelectionFlag;
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 3ded8c37e6..2d4f114638 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1868,22 +1868,19 @@ void QApplication::aboutQt()
bool QApplication::event(QEvent *e)
{
Q_D(QApplication);
- if(e->type() == QEvent::Close) {
- QCloseEvent *ce = static_cast<QCloseEvent*>(e);
- ce->accept();
+ if (e->type() == QEvent::Quit) {
closeAllWindows();
-
- const QWidgetList list = topLevelWidgets();
- for (auto *w : list) {
+ for (auto *w : topLevelWidgets()) {
if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) &&
(!(w->windowType() == Qt::Dialog) || !w->parentWidget())) {
- ce->ignore();
- break;
+ e->ignore();
+ return true;
}
}
- if (ce->isAccepted()) {
- return true;
- }
+ // Explicitly call QCoreApplication instead of QGuiApplication so that
+ // we don't let QGuiApplication close any windows we skipped earlier in
+ // closeAllWindows(). FIXME: Unify all this close magic through closeAllWindows.
+ return QCoreApplication::event(e);
#ifndef Q_OS_WIN
} else if (e->type() == QEvent::LocaleChange) {
// on Windows the event propagation is taken care by the
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index b9a67edc6a..24f8c5ce43 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -893,7 +893,7 @@ void QWidgetWindow::handleDragEnterEvent(QDragEnterEvent *event, QWidget *widget
void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event)
{
- auto *widget = findDnDTarget(m_widget, event->pos());
+ QPointer<QWidget> widget = findDnDTarget(m_widget, event->pos());
if (!widget) {
event->ignore();
if (m_dragTarget) { // Send DragLeave to previous
@@ -916,14 +916,18 @@ void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event)
QGuiApplication::forwardEvent(m_dragTarget, &leaveEvent, event);
m_dragTarget = nullptr;
}
- // Send DragEnter to new widget.
- handleDragEnterEvent(static_cast<QDragEnterEvent*>(event), widget);
- // Handling 'DragEnter' should suffice for the application.
- translated.setDropAction(event->dropAction());
- translated.setAccepted(event->isAccepted());
- // The drag enter event is always immediately followed by a drag move event,
- // see QDragEnterEvent documentation.
- QGuiApplication::forwardEvent(m_dragTarget, &translated, event);
+ // widget might have been deleted when handling the leaveEvent
+ if (widget) {
+ // Send DragEnter to new widget.
+ handleDragEnterEvent(static_cast<QDragEnterEvent*>(event), widget);
+ // Handling 'DragEnter' should suffice for the application.
+ translated.setDropAction(event->dropAction());
+ translated.setAccepted(event->isAccepted());
+ // The drag enter event is always immediately followed by a drag move event,
+ // see QDragEnterEvent documentation.
+ if (m_dragTarget)
+ QGuiApplication::forwardEvent(m_dragTarget, &translated, event);
+ }
}
event->setAccepted(translated.isAccepted());
event->setDropAction(translated.dropAction());