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);
Simple right?!
Next you apply this QRegion to your Window’s mask using the following code and it’s done:
setMask(region);
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.
Hello, how to smooth the edges? (antialiasing). THanks
Unfortunately not possible with the method described here in this post. You’ll need to look for a method to apply masks with an alpha-channel to windows as opposed to 1-bit depth masks like QBitmap
Could you check email. I have requested a tutorial suggestion on Qt Qrcode with an example. Thanks