I’m trying to make a movable window without actually creating any widgets (except a QWebView) and I’m wondering if is possible to emit QMouseEvent from JavaScript (inside QWebView) and catch the signal with C++?
I’m already aware how to call C++ methods from JS (and vice-versa) as described here but I’m asking if I’ll be able to generate/emit an event containing a QMouseEvent (that’s really important because of the current global position of the cursor).
It wasn’t that hard after all.
First of all, I exposed my window to the JavaScript engine:
Then I created a simple div inside my HTML code and attached this code to handle the mouse onClick, onMove and onDrag events.
Finally, I added two functions in my C++ code that will handle the calls from my JavaScript code:
Also, make sure that you make those functions callable from JS!