Move native subwidgets in QWidget::scroll().
Task-number: QTBUG-38999 Change-Id: Ie22dcf61895bbfc575eaae4d1929516a8749de39 Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
This commit is contained in:
parent
52ff4120a2
commit
3478ec2949
@ -609,7 +609,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
|
||||
void setWSGeometry();
|
||||
|
||||
inline QPoint mapToWS(const QPoint &p) const
|
||||
{ return p - data.wrect.topLeft(); }
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtWidgets module of the Qt Toolkit.
|
||||
@ -1027,11 +1027,11 @@ void QWidgetPrivate::setWindowOpacity_sys(qreal level)
|
||||
q->windowHandle()->setOpacity(level);
|
||||
}
|
||||
|
||||
void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
|
||||
void QWidgetPrivate::setWSGeometry()
|
||||
{
|
||||
Q_UNUSED(dontShow);
|
||||
Q_UNUSED(oldRect);
|
||||
// XXX
|
||||
Q_Q(QWidget);
|
||||
if (QWindow *window = q->windowHandle())
|
||||
window->setGeometry(data.crect);
|
||||
}
|
||||
|
||||
QPaintEngine *QWidget::paintEngine() const
|
||||
|
@ -288,6 +288,7 @@ private slots:
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
void scroll();
|
||||
void scrollNativeChildren();
|
||||
#endif
|
||||
|
||||
// tests QWidget::setGeometry()
|
||||
@ -4336,7 +4337,30 @@ void tst_QWidget::scroll()
|
||||
QTRY_COMPARE(updateWidget.paintedRegion, dirty);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// QTBUG-38999, scrolling a widget with native child widgets should move the children.
|
||||
void tst_QWidget::scrollNativeChildren()
|
||||
{
|
||||
QWidget parent;
|
||||
parent.setWindowTitle(QLatin1String(__FUNCTION__));
|
||||
parent.resize(400, 400);
|
||||
centerOnScreen(&parent);
|
||||
QLabel *nativeLabel = new QLabel(QStringLiteral("nativeLabel"), &parent);
|
||||
const QPoint oldLabelPos(100, 100);
|
||||
nativeLabel->move(oldLabelPos);
|
||||
QVERIFY(nativeLabel->winId());
|
||||
parent.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&parent));
|
||||
const QPoint delta(50, 50);
|
||||
parent.scroll(delta.x(), delta.y());
|
||||
const QPoint newLabelPos = oldLabelPos + delta;
|
||||
QWindow *labelWindow = nativeLabel->windowHandle();
|
||||
QVERIFY(labelWindow);
|
||||
QTRY_COMPARE(labelWindow->geometry().topLeft(), newLabelPos);
|
||||
QTRY_COMPARE(nativeLabel->geometry().topLeft(), newLabelPos);
|
||||
}
|
||||
|
||||
#endif // Mac OS
|
||||
|
||||
class DestroyedSlotChecker : public QObject
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user