I want to achieve something like this using QPainter
I tried using 2 rounded rectangles in QPainter side by side but I was unable to achieve the image above.
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QRectF leftRect= QRectF(0, 0, 300, 150);
QRectF rightRect= QRectF(300, 0, 300, 150);
painter.fillRect(leftRect, QColor("black");
painter.drawRoundedRect(leftRect,15,35);
painter.setPen(QPen("white"));
painter.setPen(QPen("black"));
painter.fillRect(rightRect, QColor("white");
painter.drawRoundedRect(rightRect,15,35);
This is what I tried and got this
I tried this with QPainterPath
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QRectF leftRect= QRectF(0, 0, 300, 150);
QRectF rightRect= QRectF(300, 0, 300, 150);
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRoundedRect(leftRect, 15, 35);
QPen pen(Qt::white, 1);
painter.setPen(pen);
painter.fillPath(path, Qt::black);
painter.drawPath(path);
QPainterPath path2;
path2.setFillRule(Qt::WindingFill);
QPen pen1(Qt::black, 1);
painter.setPen(pen1);
path2.addRoundedRect(rightRect, 15, 35);
painter.fillPath(path2, Qt::white);
painter.drawPath(path2);