Search code examples
qtmouseeventqthread

Is there a way to add a mouse event to a thread?


I have a suspicion that something is preventing my mouse event to be called in Qt. Therefore, I think it might help to add the event to a thread. Is there any way to do that? And if so how would the syntax look?


Solution

  • Qt standard mouse events come to QWidget objects. Those must exist in the main thread, always.

    So no, you can't receive the normal mouse events in other threads.

    However, you should perhaps install an event filter to your main window or to your qApp object, so you will see all the events. Look in the docs for how to use the event filter, but in short, you need to subclass QObject to override the eventFilter method, and then create instance of this class, and install that as event filter for another object.