From 1b8dcec81a0879843f5c3781c3b067ddb6542cbf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Nov 2012 12:42:11 +0100 Subject: Make widgetgrab manual test compile with 4.8 and 5. Task-number: QTBUG-27333 Task-number: QTBUG-27550 Change-Id: Iceb2ded9deff1d375bf02b88e214da20901bfa0e Reviewed-by: Oliver Wolff --- tests/manual/widgetgrab/main.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/widgetgrab/main.cpp b/tests/manual/widgetgrab/main.cpp index a83338e9b7..d842876faf 100644 --- a/tests/manual/widgetgrab/main.cpp +++ b/tests/manual/widgetgrab/main.cpp @@ -57,6 +57,8 @@ #include #include +// Compiles with Qt 4.8 and Qt 5. + class MainWindow : public QMainWindow { Q_OBJECT @@ -233,11 +235,15 @@ bool MainWindow::eventFilter(QObject *o, QEvent *e) if (o->isWidgetType()) { switch (e->type()) { case QEvent::Enter: { - const QEnterEvent *ee = static_cast(e); QString message; QDebug debug(&message); +#if QT_VERSION >= 0x050000 + const QEnterEvent *ee = static_cast(e); debug.nospace() << '#' << m_enterLeaveEventCount++ << " Enter for " << o->objectName() << " at " << ee->localPos() << " global: " << ee->globalPos(); +#else + debug.nospace() << '#' << m_enterLeaveEventCount++ << " Enter for " << o->objectName(); +#endif m_logEdit->appendPlainText(message); } break; @@ -363,8 +369,13 @@ void MainWindow::grabKeyboardWindowToggled(bool g) void MainWindow::forceNativeWidgets() { - m_logEdit->appendPlainText(QString::fromLatin1("Created native widget %1"). - arg(m_forceNativeButton->winId())); + const WId platformWid = m_forceNativeButton->winId(); +#if QT_VERSION < 0x050000 && defined(Q_OS_WIN) + const quintptr wid = quintptr(platformWid); // HWND on Qt 4.8/Windows. +#else + const WId wid = platformWid; +#endif + m_logEdit->appendPlainText(QString::fromLatin1("Created native widget %1").arg(wid)); m_forceNativeButton->setEnabled(false); m_forceNativeButton->setText(QLatin1String("Native widgets created")); } -- cgit v1.2.3