diff --git a/examples/activeqt/webbrowser/main.cpp b/examples/activeqt/webbrowser/main.cpp index b31add3..f7dc87c 100644 --- a/examples/activeqt/webbrowser/main.cpp +++ b/examples/activeqt/webbrowser/main.cpp @@ -50,6 +50,10 @@ #include #include +#include +#include +#include + #if defined(Q_WS_WINCE_WM) #include "ui_mainwindow_windowsmobile.h" #include @@ -122,6 +126,100 @@ static void saveBookMarks(const QList &bookmarks, QSettings &settings) settings.endArray(); } +static inline void formatObjectName(const QObject *w, QTextStream &str) +{ + str << w->metaObject()->className(); + if (!w->objectName().isEmpty()) + str << "/\"" << w->objectName() << '"'; +} + +static void dumpWindowRecursion(QTextStream &str, const QWindow *w, const QWindowList &allWins, int depth = 0) +{ + if (depth) + str << QString(depth * 2, QLatin1Char(' ')); + const QRect geom = w->geometry(); + const QPoint globalPos = w->isTopLevel() ? geom.topLeft() : w->mapToGlobal(geom.topLeft()); + formatObjectName(w, str); + str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] "); + if (w->isTopLevel()) + str << "[top] "; + if (w->surfaceType() == QSurface::OpenGLSurface) + str << "[gl] "; + const QSurfaceFormat format = w->requestedFormat(); + if (format.hasAlpha()) + str << "[alpha] "; + str << "f=0x" << hex << unsigned(w->flags()) << dec + << "\" " << geom.width() << 'x' << geom.height() + << forcesign << geom.x() << geom.y() + << " Global: " << globalPos.x() << globalPos.y() << noforcesign << '\n'; + foreach (const QWindow *cw, allWins) + if (cw->type() != Qt::Desktop && cw->parent() == w) + dumpWindowRecursion(str, cw, allWins, depth + 1); +} +static void dumpAllWindows() +{ + QString d; + QWindowList wins = QGuiApplication::allWindows(); + QTextStream str(&d); + foreach (const QWindow *w, wins) + if (w->type() != Qt::Desktop && w->isTopLevel()) + dumpWindowRecursion(str, w, wins, 0); + qDebug().nospace() << d; +} + + +static void dumpWidgetRecursion(QTextStream &str, const QWidget *w, int depth = 0) +{ + if (depth) + str << QString(depth * 2, QLatin1Char(' ')); + const QRect geom = w->geometry(); + const QPoint globalPos = w->isWindow() ? geom.topLeft() : w->mapToGlobal(geom.topLeft()); + formatObjectName(w, str); + str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] ") + << "focuspol: " << w->focusPolicy() << ' '; +#if QT_VERSION >= 0x050000 + if (const QWindow *wh = w->windowHandle()) { + str << "[qwin: "; + formatObjectName(wh, str); + str << ']'; + } +#endif + if (const QWidget *fp = w->focusProxy()) { + str << "[focusproxy: "; + formatObjectName(fp, str); + str << ']'; + } + if (!w->isEnabled()) + str << "[disabled]"; + if (w->hasFocus()) + str << "[focus]"; + if (w->isWindow()) + str << "[top] "; + if (w->internalWinId()) + str << "[internalWinId] "; + if (w->testAttribute(Qt::WA_Mapped)) + str << "[mapped] "; + if (w->acceptDrops()) + str << "[drops] "; + str << "f=0x" << hex << unsigned(w->windowFlags()) << dec + << "\" " << geom.width() << 'x' << geom.height() + << forcesign << geom.x() << geom.y() + << " Global: " << globalPos.x() << globalPos.y() << noforcesign << '\n'; + foreach (const QObject *co, w->children()) + if (co->isWidgetType()) { + const QWidget *cw = static_cast(co); + dumpWidgetRecursion(str, cw, depth + 1); + } +} + +static void dumpWidgets(const QWidget *w) +{ + QString d; + QTextStream str(&d); + dumpWidgetRecursion(str, w); + qDebug().nospace() << d; +} + //! [0] class MainWindow : public QMainWindow, public Ui::MainWindow { @@ -341,6 +439,8 @@ int main(int argc, char ** argv) #else w.show(); #endif + dumpAllWindows(); + dumpWidgets(&w); return a.exec(); } //! [4] diff --git a/examples/activeqt/webbrowser/webaxwidget.h b/examples/activeqt/webbrowser/webaxwidget.h index 4a34a12..5c27197 100644 --- a/examples/activeqt/webbrowser/webaxwidget.h +++ b/examples/activeqt/webbrowser/webaxwidget.h @@ -55,10 +55,13 @@ public: protected: virtual bool translateKeyEvent(int message, int keycode) const { + bool rc = false; if (message >= WM_KEYFIRST && message <= WM_KEYLAST) - return true; + rc = true; else - return QAxWidget::translateKeyEvent(message, keycode); + rc = QAxWidget::translateKeyEvent(message, keycode); + qDebug() << __FUNCTION__ << rc; + return rc; } }; diff --git a/examples/activeqt/webbrowser/webbrowser.pro b/examples/activeqt/webbrowser/webbrowser.pro index 9fa342b..c961c6f 100644 --- a/examples/activeqt/webbrowser/webbrowser.pro +++ b/examples/activeqt/webbrowser/webbrowser.pro @@ -1,7 +1,7 @@ TEMPLATE = app QT += widgets axcontainer - +CONFIG+=console HEADERS = webaxwidget.h SOURCES = main.cpp FORMS = mainwindow.ui @@ -11,3 +11,4 @@ wincewm*: FORMS = mainwindow_windowsmobile.ui # install target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/webbrowser INSTALLS += target +CONFIG+=console