Drawing Rectangle with only 2 corners rounded in Qt

qt

Solution

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

Problem

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

Original source