What is discussed here is the implementation on the Windows platform.
In QT to draw the special-shaped window, as long as set windowflag for Customizewindowhint, and then combined with setmask () can make a variety of grotesque window. Relatively troublesome is the processing of window dragging and zooming.
In the Windows SDK and MFC is relatively easy, as long as the processing of wm_nchittest, the corresponding test values can be returned. Fortunately, QT also provides a way to directly process each platform message, and in Windows you only need to overload the WinEvent method.
The sample code is given below:
//include <windows.h>BOOLMydialog::winevent (msg* MSG,Long*result) { Const intCaptionHeight = -; Const intFramewidth =6; if(Msg->message! = wm_nchittest)return false; Qpoint POS=Mapfromglobal (qcursor::p OS ()); intW =width (); inth =height (); if(Qrect (Framewidth, CaptionHeight, W-framewidth-framewidth, h-captionheight-framewidth). Contains (POS)) {*result =htclient; } Else if(Qrect (0,0, W, CaptionHeight). Contains (POS)) {*result =htcaption; } Else if(Qrect (0, CaptionHeight, Framewidth, h-captionheight-framewidth). Contains (POS)) {*result =Htleft; } Else if(Qrect (W-framewidth, CaptionHeight, Framewidth, h-captionheight-framewidth). Contains (POS)) {*result =Htright; } Else if(Qrect (Framewidth, H-framewidth, w-framewidth-framewidth, Framewidth). Contains (POS)) {*result =Htbottom; } Else if(Qrect (0, H-framewidth, Framewidth, Framewidth). Contains (POS)) {*result =Htbottomleft; } Else if(Qrect (W-framewidth, Hframewidth, Framewidth, Framewidth). Contains (POS)) {*result =Htbottomright; } return true;}
Reference: http://www.cppblog.com/eXile/archive/2007/12/09/38084.html
Drawing of special-shaped windows in Qt (winevent processing wm_nchittest messages)