By default every window you create has a rectangular shape but in case you want to have a window which is non-rectangular (such as ellipse or triangle or any shape you prefer) then you can use the approach below.
In this example I’ll create an ellipse window (as seen below) but the approach is correct in case of any other shape you want.
First you need to create a QRegion. This is in fact the region that you want to remain visible. So I am going to create an ellipse region which has the same width and height as the window itself using the following code:
QRegion region(rect(), QRegion::Ellipse);
Next you apply this QRegion to your Window’s mask using the following code and it’s done:
Note that you have to write both of these lines in your window’s constructor function.
One more this to note is that you can in fact apply a QBitmap, that is a bitmap that you have created, to the setMask function above and you can have Windows with any other shapes.