Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QBenchmarkEvent Class Reference

#include <qbenchmarkevent_p.h>

+ Inheritance diagram for QBenchmarkEvent:
+ Collaboration diagram for QBenchmarkEvent:

Public Member Functions

 QBenchmarkEvent ()
 
 ~QBenchmarkEvent ()
 
void start () override
 
QList< Measurementstop () override
 
bool isMeasurementAccepted (Measurement measurement) override
 
int adjustIterationCount (int suggestion) override
 
int adjustMedianCount (int suggestion) override
 
bool nativeEventFilter (const QByteArray &eventType, void *message, qintptr *result) override
 This method is called for every native event.
 
- Public Member Functions inherited from QBenchmarkMeasurerBase
virtual ~QBenchmarkMeasurerBase ()=default
 
virtual void init ()
 
virtual bool needsWarmupIteration ()
 
- Public Member Functions inherited from QAbstractNativeEventFilter
 QAbstractNativeEventFilter ()
 Creates a native event filter.
 
virtual ~QAbstractNativeEventFilter ()
 Destroys the native event filter.
 

Public Attributes

qint64 eventCounter = 0
 

Detailed Description

Definition at line 25 of file qbenchmarkevent_p.h.

Constructor & Destructor Documentation

◆ QBenchmarkEvent()

QT_BEGIN_NAMESPACE QBenchmarkEvent::QBenchmarkEvent ( )
default

◆ ~QBenchmarkEvent()

QBenchmarkEvent::~QBenchmarkEvent ( )
default

Member Function Documentation

◆ adjustIterationCount()

int QBenchmarkEvent::adjustIterationCount ( int suggestion)
overridevirtual

Implements QBenchmarkMeasurerBase.

Definition at line 36 of file qbenchmarkevent.cpp.

◆ adjustMedianCount()

int QBenchmarkEvent::adjustMedianCount ( int suggestion)
overridevirtual

Implements QBenchmarkMeasurerBase.

Definition at line 41 of file qbenchmarkevent.cpp.

References Q_UNUSED.

◆ isMeasurementAccepted()

bool QBenchmarkEvent::isMeasurementAccepted ( QBenchmarkMeasurerBase::Measurement measurement)
overridevirtual

Implements QBenchmarkMeasurerBase.

Definition at line 30 of file qbenchmarkevent.cpp.

References Q_UNUSED.

◆ nativeEventFilter()

bool QBenchmarkEvent::nativeEventFilter ( const QByteArray & eventType,
void * message,
qintptr * result )
overridevirtual

This method is called for every native event.

Note
The filter function here receives native messages, for example, MSG or XCB event structs.

It is called by the QPA platform plugin. On Windows, it is called by the event dispatcher.

The type of event eventType is specific to the platform plugin chosen at run-time, and can be used to cast message to the right type.

On X11, eventType is set to "xcb_generic_event_t", and the message can be casted to a xcb_generic_event_t pointer.

On Windows, eventType is set to "windows_generic_MSG" for messages sent to toplevel windows, and "windows_dispatcher_MSG" for system-wide messages such as messages from a registered hot key. In both cases, the message can be casted to a MSG pointer. The result pointer is only used on Windows, and corresponds to the LRESULT pointer.

On macOS, eventType is set to "mac_generic_NSEvent", and the message can be casted to an NSEvent pointer.

In your reimplementation of this function, if you want to filter the message out, i.e. stop it being handled further, return true; otherwise return false.

{Linux example}

{
public:
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override
{
if (eventType == "xcb_generic_event_t") {
xcb_generic_event_t* ev = static_cast<xcb_generic_event_t *>(message);
// ...
}
return false;
}
};
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override
This method is called for every native event.
ptrdiff_t qintptr
Definition qtypes.h:166

{Windows example}

{
public:
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override
{
if (eventType == "windows_generic_MSG") {
MSG *msg = static_cast<MSG *>(message);
// ...
} else if (eventType == "windows_dispatcher_MSG") {
MSG *msg = static_cast<MSG *>(message);
// ...
}
return false;
}
};
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override
This method is called for every native event.
struct tagMSG MSG

{macOS example}

mycocoaeventfilter.h:

#include <QAbstractNativeEventFilter>
{
public:
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override;
};
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override
[0]

mycocoaeventfilter.mm:

#include "mycocoaeventfilter.h"
#import <AppKit/AppKit.h>
{
if (eventType == "mac_generic_NSEvent") {
NSEvent *event = static_cast<NSEvent *>(message);
if ([event type] == NSKeyDown) {
// Handle key event
qDebug() << QString::fromNSString([event characters]);
}
}
return false;
}

myapp.pro:

HEADERS += mycocoaeventfilter.h
OBJECTIVE_SOURCES += mycocoaeventfilter.mm
LIBS += -framework AppKit

Implements QAbstractNativeEventFilter.

Definition at line 49 of file qbenchmarkevent.cpp.

References Q_UNUSED.

◆ start()

void QBenchmarkEvent::start ( )
overridevirtual

Implements QBenchmarkMeasurerBase.

Definition at line 15 of file qbenchmarkevent.cpp.

References eventCounter, and QAbstractEventDispatcher::instance().

+ Here is the call graph for this function:

◆ stop()

QList< QBenchmarkMeasurerBase::Measurement > QBenchmarkEvent::stop ( )
overridevirtual

Implements QBenchmarkMeasurerBase.

Definition at line 21 of file qbenchmarkevent.cpp.

References eventCounter, QTest::Events, and QAbstractEventDispatcher::instance().

+ Here is the call graph for this function:

Member Data Documentation

◆ eventCounter

qint64 QBenchmarkEvent::eventCounter = 0

Definition at line 40 of file qbenchmarkevent_p.h.

Referenced by start(), and stop().


The documentation for this class was generated from the following files: