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 0000000000..de03f7b6d4 --- /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 7a323e30a2..7b31c0fac5 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: