I am working on an application where I need to fill the color for the Pixmap using Painter. Pixmap is of type rectangle with (bottom edge) 2 rounded corners. Top 2 corners are flat/normal.
I tried to use the drawRoundedRect() API of Qt, but it makes all the corners of the rectangle rounded. I need to draw the rectangle with only 2 corners rounded and other two flat.
If anyone comes across the situation, please suggest me the solution.
Thanks
Definition of ROUNDED CORNER RECTANGLES:Labels that are rectangular in shape and have rounded corners; the corners do not form a sharp point, but instead are curved into an arc.
The word "squircle" is a portmanteau of the words "square" and "circle". Squircles have been applied in design and optics.
You can use QPainterPath for that :
QPainterPath path;
path.setFillRule( Qt::WindingFill );
path.addRoundedRect( QRect(50,50, 200, 100), 20, 20 );
path.addRect( QRect( 200, 50, 50, 50 ) ); // Top right corner not rounded
path.addRect( QRect( 50, 100, 50, 50 ) ); // Bottom left corner not rounded
painter.drawPath( path.simplified() ); // Only Top left & bottom right corner rounded
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With