From b6ce61f486a06ded273d518d871906f9a53ab7c1 Mon Sep 17 00:00:00 2001 From: Kari Hormi Date: Mon, 7 Oct 2019 16:21:33 +0300 Subject: Fix text not rendering properly after setAlignment call Sometimes when setAlignment is called, the text stops rendering correctly at some point. Adding relayoutDocument call to setAlignment fixes the problem. Fixes: QTBUG-78728 Change-Id: Iab1cf161f0c8d700804448733338c813b5bf9762 Reviewed-by: Ville Voutilainen --- src/widgets/widgets/qtextedit.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets/widgets') diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 0ae63f2dd5..2b3a46ae56 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -746,6 +746,7 @@ void QTextEdit::setAlignment(Qt::Alignment a) QTextCursor cursor = d->control->textCursor(); cursor.mergeBlockFormat(fmt); d->control->setTextCursor(cursor); + d->relayoutDocument(); } /*! -- cgit v1.2.3 From f1dd6addda908185f497d299d706b88977dea858 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 2 Oct 2019 12:19:11 +0200 Subject: Make QTextBlockFormat::MarkerType an enum class This came up during API review. Change-Id: I9198e1eb96db0c21e46a226a032919bb62d3ca66 Reviewed-by: Giuseppe D'Angelo --- src/widgets/widgets/qtextedit.cpp | 2 +- src/widgets/widgets/qwidgettextcontrol.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/widgets/widgets') diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 0702603648..dd2ea3f18f 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -237,7 +237,7 @@ void QTextEditPrivate::_q_hoveredBlockWithMarkerChanged(const QTextBlock &block) Qt::CursorShape cursor = cursorToRestoreAfterHover; if (block.isValid() && !q->isReadOnly()) { QTextBlockFormat::MarkerType marker = block.blockFormat().marker(); - if (marker != QTextBlockFormat::NoMarker) { + if (marker != QTextBlockFormat::MarkerType::NoMarker) { if (viewport->cursor().shape() != Qt::PointingHandCursor) cursorToRestoreAfterHover = viewport->cursor().shape(); cursor = Qt::PointingHandCursor; diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index fdbaf29dd8..094c59a0c9 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1810,11 +1810,11 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but if (markerBlock == blockWithMarkerUnderMouse) { auto fmt = blockWithMarkerUnderMouse.blockFormat(); switch (fmt.marker()) { - case QTextBlockFormat::Unchecked : - fmt.setMarker(QTextBlockFormat::Checked); + case QTextBlockFormat::MarkerType::Unchecked : + fmt.setMarker(QTextBlockFormat::MarkerType::Checked); break; - case QTextBlockFormat::Checked: - fmt.setMarker(QTextBlockFormat::Unchecked); + case QTextBlockFormat::MarkerType::Checked: + fmt.setMarker(QTextBlockFormat::MarkerType::Unchecked); break; default: break; -- cgit v1.2.3 From 65fcd8524da628c99e8cd28f983f0c17fbe157f0 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 8 Oct 2019 16:25:08 +0200 Subject: QAbstractScrollArea: when used as a popup, apply regular popup behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWidget::mousePressEvent is documented to implement the closing of popups if the widget is a popup. QAbstractScrollArea is one of the QWidget subclasses that might be used as a popup as well, so instead of just ignoring mousePressEvents, pass the event on to the QWidget implementation for regular popup handling. Change-Id: I05f77a334945f3c167f729f30bc022599230379b Fixes: QTBUG-60885 Reviewed-by: Tor Arne Vestbø Reviewed-by: Paul Olav Tvete --- src/widgets/widgets/qabstractscrollarea.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/widgets/widgets') diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index b295e66574..d2372a7be9 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1144,11 +1144,14 @@ void QAbstractScrollArea::paintEvent(QPaintEvent*) mouse press events for the viewport() widget. The event is passed in \a e. + The default implementation calls QWidget::mousePressEvent() for + default popup handling. + \sa QWidget::mousePressEvent() */ void QAbstractScrollArea::mousePressEvent(QMouseEvent *e) { - e->ignore(); + QWidget::mousePressEvent(e); } /*! -- cgit v1.2.3 From 1748dc3e2d2367f9f01666212a22e6b1dde5dc89 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 7 Oct 2019 16:09:37 +0200 Subject: QGroupBox: always disable children in a checkable, unchecked groupbox The childEvent handler sets the enabled property of children as they are added to the groupbox, but applications might later enable children and check/uncheck the groupbox's checkbox in undefined order. In that case, we would end up with enabled children inside a conceptually disabled groupbox (the groupbox's checkbox represents the logical "disabled" state), which breaks documented QWidget::enabled rules. To make sure that all children are disabled as per the state of the groupbox, we need to run that logic once the UI has been set up, and before it becomes visible. This is what polishing is for, so listen for that event in addition and handle it the same way as adding (which duplicates things, but keeps existing code that might depend on things being updated as they are added working). Adds the case to the existing enabledChildPropagation test case. [ChangeLog][QWidget][QGroupBox] Always disable children of a checkable, unchecked group box before showing. Change-Id: I978bd27b6f1a3f54ec745faeea529a98d0d93619 Fixes: QTBUG-25938 Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qgroupbox.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/widgets/widgets') diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp index 69eac1ebf7..eec794562a 100644 --- a/src/widgets/widgets/qgroupbox.cpp +++ b/src/widgets/widgets/qgroupbox.cpp @@ -389,9 +389,13 @@ bool QGroupBox::event(QEvent *e) void QGroupBox::childEvent(QChildEvent *c) { Q_D(QGroupBox); - if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType()) + /* + Children might have been enabled after being added to the group box, in which case + the childEvent handler ran too early, and we need to disabled children again. + */ + if (!(c->added() || c->polished()) || !c->child()->isWidgetType()) return; - QWidget *w = (QWidget*)c->child(); + QWidget *w = static_cast(c->child()); if (w->isWindow()) return; if (d->checkable) { -- cgit v1.2.3