how can i use round buttons and put the in a layout without lose their shape
-
@Giakara
You need to set them a fixed size,
or to define a prefered one by implementing :
virtual QSize sizeHint() constalso is there a better way to create round buttons?
Better way than what ?
[EDIT] In fact I don't understand the question, because putting a widget in a layout can only change its size not its shape ...
-
y sorry i used this code
QPushButton {
color: #333;
border: 2px solid #555;
border-radius: 20px;
border-style: outset;
background: qradialgradient(
cx: 0.3, cy: -0.4, fx: 0.3, fy: -0.4,
radius: 1.35, stop: 0 #fff, stop: 1 #888
);
padding: 5px;
}QPushButton:hover {
background: qradialgradient(
cx: 0.3, cy: -0.4, fx: 0.3, fy: -0.4,
radius: 1.35, stop: 0 #fff, stop: 1 #bbb
);
} -
@Giakara with set fixed size, example:
for(int i=0;i<3;i++)
{
QPushButton * button = new QPushButton;
button->setText(QString::number(i+1));
button->setFixedSize(100,100);
QRect rect(QPoint(), button->size());
rect.adjust(10, 10, -10, -10);
QRegion region(rect,QRegion::Ellipse);
button->setMask(region);
horizontalLayout->addWidget(button);
}