Qt4 debug tips-top the qt4 window. It will not be behind vs. It cannot be seen.

Source: Internet
Author: User

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.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.