Custom Event Compression
-
You have to subclass Q(Core)Application (depending on whether you want gui or not) and then overwrite the compressEvent function. And don't forget to call the parent function at the end so that the standard events are compressed (a little plagarism from QApplication):
@
bool MyApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents)
{
if(event->type()==MyEventType)
{
for (int i = 0; i < postedEvents->size(); ++i) {
const QPostEvent &cur = postedEvents->at(i);
if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type())
continue;
delete event;
return true;
}
return false;
}
return QCoreApplication::compressEvent(event, receiver, postedEvents);
}
@ -
Created a bug since this isn't documented."Bug Report":https://bugreports.qt.io/browse/QTBUG-19711