Domanda

My program is working on Qt, and I have a problem and there is free answer for it in website. Our products need to update image while user move mouse, but the updating image is very time-consuming.If user move the mouse quickly, the system will generate a lot of mouse movement events, eventually leading to clogging of the background process.Therefore, we need to filter out part of the event. I filter mouse move event by insert event filter in QApplication:

qApp->insertEventFilter(this)

Once I catch mouse event, I will store QMouseEvent and pointer of QObject, and active QTimer. other mouseMouseEvent will can overwrite them before timeout. After timeout, the last event will be post. I can't use:

QApplication::sendEvent(XX) or postEvent(xx)

because it will be catched by my event filter again. How can I make it work?

È stato utile?

Soluzione

Don't filter the events. Instead of that, change your background worker which is responsible for producing the data to make sure that you do not spend time on stuff you won't need.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top