I'm trying to develop Reversi using C++ for core and Qt for GUI. But, I'm having some trouble drawing circle with QGraphics. I'm trying to make circle in picture below transparent but border is not getting transparent. Is there any option that to make QGraphicsEllipseItem's border transparent?
QGraphicsScene *scene = new QGraphicsScene(ui->gv_main);
scene->setSceneRect(0, 0, 667, 667);
ui->gv_main->setScene(scene);
const int DIAMETER = 80;
auto circle = new QGraphicsEllipseItem(0, 0, DIAMETER, DIAMETER);
circle->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
circle->setBrush(Qt::black);
circle->setPos(2,2);
scene->addItem(circle);
auto circle2 = new QGraphicsEllipseItem(0, 0, DIAMETER, DIAMETER);
circle2->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
circle2->setBrush(Qt::transparent);
circle2->setPos(85,2);
scene->addItem(circle2);
You don't have to make it transparent but remove it by setting it as Qt::NoPen
with QPen
of the item:
circle2->setPen(Qt::NoPen);