From aa694575331ea0bda30cb4cc76174ced4d20df89 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Mon, 1 Aug 2022 19:10:48 +0100 Subject: [PATCH] QAbstractNativeEventFilter: Add a Windows example Change-Id: Ic378174e7f192abc27524cbcd925705c8bb46502 Reviewed-by: Thiago Macieira --- ..._kernel_qabstractnativeeventfilter_win.cpp | 20 +++++++++++++++++++ .../kernel/qabstractnativeeventfilter.cpp | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter_win.cpp diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter_win.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter_win.cpp new file mode 100644 index 00000000000..de03f7b6d4a --- /dev/null +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter_win.cpp @@ -0,0 +1,20 @@ +// Copyright (C) 2022 Laszlo Papp +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +//! [0] +class MyMSGEventFilter : public QAbstractNativeEventFilter +{ +public: + bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override + { + if (eventType == "windows_generic_MSG") { + MSG *msg = static_cast(message); + // ... + } else if (eventType == "windows_dispatcher_MSG") { + MSG *msg = static_cast(message); + // ... + } + return false; + } +}; +//! [0] diff --git a/src/corelib/kernel/qabstractnativeeventfilter.cpp b/src/corelib/kernel/qabstractnativeeventfilter.cpp index 7a323e30a2d..7b31c0fac56 100644 --- a/src/corelib/kernel/qabstractnativeeventfilter.cpp +++ b/src/corelib/kernel/qabstractnativeeventfilter.cpp @@ -69,6 +69,9 @@ QAbstractNativeEventFilter::~QAbstractNativeEventFilter() \b {Linux example} \snippet code/src_corelib_kernel_qabstractnativeeventfilter.cpp 0 + \b {Windows example} + \snippet code/src_corelib_kernel_qabstractnativeeventfilter_win.cpp 0 + \b {macOS example} mycocoaeventfilter.h: