Writing a program, especially developing a game application, is the most important thing to do is to see the running results. If you cannot see the instant effect of current screen flushing during debugging, you will feel very uncomfortable.
In fact, this article only mentions one sentence to solve this problem.
During Windows API development, you can
Hwnd createmediawex (
DWORD dwexstyle,
Maid,
Lptstr lpwindowname,
DWORD dwstyle,
Int X,
Int y,
Int nwidth,
Int nheight,
Hwnd hwndparent,
Hmenu,
Hinstance,
Lpvoid lpparam
);
When dwexstyle is set to top, the system will not be behind the window. This will show the complete debug effect.
But qt4 does not have the createmediawex condition. It is qwidget... what should I do.
In fact, there is another function that can be set to Windows.
Bool setwindowpos (
Hwnd,
Hwnd hwndinsertafter,
Int X,
Int y,
Int CX,
Int cy,
Uint uflags
);
OK. You can solve these problems by using this function.
The first parameter: Get the Windows handle. QT provides an instance with a handle for each widget. It is very easy to get the handle.
WID qwidget: winid () const (qwidget obtains the hwind function ).
Second parameter: Set the window behavior hwnd_topmost)
Third parameter: Set the X position of the window on the screen. (It is based on the point in the upper left corner)
Fourth parameter: Set the position y of the window on the screen. (It is based on the point in the upper left corner)
Fifth parameter: Set the window width
Sixth parameter: Set the window height
Seventh parameter: Set the window flag
Instance:
Qtswidget: qtswidget (qwidget * parent)
: Qwidget (parent)
{
Setwindowpos (winid (), hwnd_topmost,
Wagner-winwid, 100, winwid, winhgt, swp_showwindow );
........................................ ......
}
In this way, the debug qt4 program window will not be followed.