During this time, I used the QT development project and encountered some problems. After several days of hard work, I finally got it done, so I wrote down the solution.
1. First, the problem of flickering transparent windows in front of the video
At the beginning, I used layout management to add four widgets to a dialog. However, after the dialog is set to transparent, the video frames are rerefreshed and re-painted. Therefore, when the widget is constructed with no parent object, it is regarded as a window and transparent, and the flickering problem is solved successfully.
2. Questions about keyboard mouse Simulation
I found some methods on the Internet, but mainly used eventfilter. Add the following code in it:
Case QT: key_w:
POs. sety (Pos. Y ()-10 );
Qcursor: setpos (POS );
Break;
Case QT: key_l:
Qmouseevent * mevnpress;
Qmouseevent * mevnrelease;
Mevnpress = new qmouseevent (qevent: mousebuttonpress, POs, QT: leftbutton, QT: nobutton, QT: nomodifier );
Mevnrelease = new qmouseevent (qevent: mousebuttonrelease, POs, QT: leftbutton, QT: nobutton, QT: nomodifier );
Qcoreapplication: postevent (OBJ, mevnpress );
Qcoreapplication: postevent (OBJ, mevnrelease );
Break;
However, this is not a good solution for me. I have to add the above code for each dialog and modify the code according to each dialog. In short, it is not universal.
Inspired by x11eventfilter, wineventfilter is found. Because the underlying messages all pass through this function, we can intercept Keyboard Events, and then post the corresponding mouse events in the postmessage. OK!
The Code is as follows:
Bool wineventfilter (MSG * MSG, long * result)
{
Qdebug ("OK ");
If (MSG-> message = wm_keydown)
{
If (MSG-> wparam = vk_f2) // intercept F2 keyboard messages
{
Qpoint Pos;
Pos = qcursor: pos ();
Point point;
Point. x = pos. X ();
Point. Y = pos. Y ();
Hwnd H = windowfrompoint (point); // obtain the window handle at the mouse position
Screentoclient (H, & Point); // convert the global coordinates of the mouse to the local coordinates of the relative window
// Send the right-click message
Postmessage (H, wm_rbuttondown, mk_lbutton, makelong (point. X, point. y); // right-click and press
Postmessage (H, wm_rbuttonup, mk_lbutton, makelong (point. X, point. y); // right-click to release
}
}
Return false;
}
Sometimes it is better to go deeper at the bottom layer.