QWidgetWindow: The alien widget should be from the window's hierarchy

This partially reverts commit 025d6a778c.

Change-Id: I7b964b0d598abe46137c22177fe2b5dcca5bb812
Task-number: QTBUG-49831
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
bb10
Gabriel de Dietrich 2015-12-09 16:57:54 -08:00
parent e96fa5a780
commit 64481bcc67
2 changed files with 33 additions and 1 deletions

View File

@ -445,7 +445,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
receiver = popupChild;
if (receiver != popup)
widgetPos = receiver->mapFromGlobal(event->globalPos());
QWidget *alien = receiver->childAt(receiver->mapFromGlobal(event->globalPos()));
QWidget *alien = m_widget->childAt(m_widget->mapFromGlobal(event->globalPos()));
QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers());
QGuiApplicationPrivate::setMouseEventSource(&e, QGuiApplicationPrivate::mouseEventSource(event));
e.setTimestamp(event->timestamp());

View File

@ -165,6 +165,7 @@ private slots:
void setCustomModelAndView();
void updateDelegateOnEditableChange();
void task_QTBUG_39088_inputMethodHints();
void task_QTBUG_49831_scrollerNotActivated();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@ -3184,5 +3185,36 @@ void tst_QComboBox::task_QTBUG_39088_inputMethodHints()
QCOMPARE(box.lineEdit()->inputMethodHints(), Qt::ImhNoPredictiveText);
}
void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated()
{
QStringList modelData;
for (int i = 0; i < 1000; i++)
modelData << QStringLiteral("Item %1").arg(i);
QStringListModel model(modelData);
QComboBox box;
box.setModel(&model);
box.setCurrentIndex(500);
box.show();
QTest::qWaitForWindowShown(&box);
QTest::mouseMove(&box, QPoint(5, 5), 100);
box.showPopup();
QFrame *container = box.findChild<QComboBoxPrivateContainer *>();
QVERIFY(container);
QTest::qWaitForWindowShown(container);
QList<QComboBoxPrivateScroller *> scrollers = container->findChildren<QComboBoxPrivateScroller *>();
// Not all styles support scrollers. We rely only on those platforms that do to catch any regression.
if (!scrollers.isEmpty()) {
Q_FOREACH (QComboBoxPrivateScroller *scroller, scrollers) {
if (scroller->isVisible()) {
QSignalSpy doScrollSpy(scroller, SIGNAL(doScroll(int)));
QTest::mouseMove(scroller, QPoint(5, 5), 500);
QTRY_VERIFY(doScrollSpy.count() > 0);
}
}
}
}
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"