I'm creating a round context menu using QFrame
.
To make round corner, I used Qt style sheet :
this->setStyleSheet("QFrame#ShareContextMenu{
background-color:rgb(255,255,255);
border-width:1px;
border-color :rgb(0,0,0);
border-radius:10px;
border-style:solid;}
QPushButton{background-color:rgba(255,255,255,0);}
QPushButton::hover{background-color:rgba(125,125,125,50); border-radius:5px;}");
How can I remove the white background marked with red circles in this picture?
I think you cannot resolve the problem using style sheets. QMenu
is a rectangular top-level widget.
Is this
your QMenu
? If so, try this:
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
Replace this
by your instantiated QMenu
object.
Of course, you could also use setMask to hide the required region. For example:
QRegion region (menu->x(),
menu->y(),
menu->sizeHint().width(),
menu->sizeHint().height(),
QRegion::Ellipse);
menu->setMask(region);