/// =============Implement the upper and lower corner arc ========== setWindowFlags (Qt: FramelessWindowHint ); QBitmap bmp (this-> size (); bmp. fill (); QPainter p (& bmp); // p. setPen (Qt: NoPen); // p. setBrush (Qt: black); p. setRenderHint (QPainter: Antialiasing); // anti-aliasing // p. drawRoundedRect (bmp. rect (), 20, 20); // all the four corners are arcs // as long as the upper corner arc int arcR = 10; // radian QRect rect = this-> rect (); QPainterPath path; // counterclockwise path. moveTo (arcR, 0); path. arcTo (0, 0, arcR * 2, arcR * 2, 90.0f, 90.0f); path. lineTo (0, rect. height (); path. lineTo (rect. width (), rect. height (); path. lineTo (rect. width (), arcR); path. arcTo (rect. width ()-arcR * 2, 0, arcR * 2, arcR * 2, 0.0f, 90.0f); path. lineTo (arcR, 0); p. drawPath (path); // p. fillPath (path, QBrush (Qt: Red); // if this line of code is not available on arm and windows, a transparent empty box setMask (bmp) is displayed ); // ============ achieve the top corner arc ==============
It can be placed in the constructor of the form. I have not read the specific code principle in detail. Here, I will give you an idea ,:-).
The principle should be to use a BITMAP to draw a form. The rounded corner is gradually drawn using the path.
From: http://blog.csdn.net/fariel_zhang/article/details/6315463
Some drawing principles can be referred to: http://blog.sina.com.cn/s/blog_83dddc170100s0u4.html