Drawing Rectangle with only 2 corners rounded in Qt

前端 未结 3 1803
谎友^
谎友^ 2021-01-12 11:46

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 a

3条回答
  •  天涯浪人
    2021-01-12 12:09

    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
    

提交回复
热议问题