qlabel border radius stylesheet
-
i have a qlabel on which i set a stylesheet. all properties work except
border-radius: 25px;
. i've tried to replace the label withQPushButton
but it didn't help, so the problem isn't the label -
i have a qlabel on which i set a stylesheet. all properties work except
border-radius: 25px;
. i've tried to replace the label withQPushButton
but it didn't help, so the problem isn't the label@user4592357
Can you post how to setStyleSheet in your QLabel ? -
const auto entryLabel = new QLabel { entryText, this }; entryLabel->setStyleSheet("margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;"); m_pEntriesLayout->addWidget(entryLabel, 0, Qt::AlignCenter);
-
const auto entryLabel = new QLabel { entryText, this }; entryLabel->setStyleSheet("margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;"); m_pEntriesLayout->addWidget(entryLabel, 0, Qt::AlignCenter);
@user4592357
its works for me:auto entryLabel = new QLabel("My Label"); entryLabel->setStyleSheet("QLabel{margin-left: 10px; border-radius: 25px; background: red; color: #4A0C46;}"); ui->gridLayout->addWidget(entryLabel);
-
const auto entryLabel = new QLabel { entryText, this }; entryLabel->setStyleSheet("margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;"); m_pEntriesLayout->addWidget(entryLabel, 0, Qt::AlignCenter);
@user4592357 Hi,friend. Welcome.
Try below snippet:
entryLabel->setStyleSheet("QLabel{margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;}");
-
@user4592357 Hi,friend. Welcome.
Try below snippet:
entryLabel->setStyleSheet("QLabel{margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;}");
@joeQ i had tried that too.
@Taz742, doesn't work for me
i'm placing the label in one of
QStackedWidget
's widget, which is a member in aQWidget
subclass, and on that subclass i set style sheet too. i thought that was the problem, but i added theborder-radius
part to that style sheet and it still doesn't work -
const auto entryLabel = new QLabel { entryText, this }; entryLabel->setStyleSheet("margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;"); m_pEntriesLayout->addWidget(entryLabel, 0, Qt::AlignCenter);
@user4592357
whats the actuall size of the Label? if its below 50 pxl, no rounded corners will be drawn, also you'll most likly need to specify a border color:this for example, works fine for me
const auto entryLabel = new QLabel { "Blablabla"}; entryLabel->setStyleSheet("margin-left: 10px; border: 1px solid black; border-radius: 25px; background: white; color: red;"); entryLabel->show(); entryLabel->resize(100,100);
-
@user4592357
whats the actuall size of the Label? if its below 50 pxl, no rounded corners will be drawn, also you'll most likly need to specify a border color:this for example, works fine for me
const auto entryLabel = new QLabel { "Blablabla"}; entryLabel->setStyleSheet("margin-left: 10px; border: 1px solid black; border-radius: 25px; background: white; color: red;"); entryLabel->show(); entryLabel->resize(100,100);
@J.Hilk didn't work for me. and i set no size but the text is long enough (def larger than 50px)
-
@J.Hilk didn't work for me. and i set no size but the text is long enough (def larger than 50px)
@user4592357 height also > 50?
-
@user4592357 height also > 50?
@J.Hilk i set (100, 100) as you and didn't get any result
-
@J.Hilk i set (100, 100) as you and didn't get any result
@user4592357 my example was explicitly without parent, for testing purpose.
If your label is managed by anything else, a Layout for example,entryLabel->resize(100,100);
has quite literly no effect on your label. -
@user4592357 my example was explicitly without parent, for testing purpose.
If your label is managed by anything else, a Layout for example,entryLabel->resize(100,100);
has quite literly no effect on your label.@J.Hilk yes, it's in a layout. so what should i do?
-
@J.Hilk yes, it's in a layout. so what should i do?
@user4592357
You can use label->setMinimumSize(QSize(100,100)); -
@user4592357
You can use label->setMinimumSize(QSize(100,100));@mrjj finally works, thanks!
-
@mrjj finally works, thanks!
@user4592357
Super
It also fooled me in the beginning.
As soon as a Widget is in a layout, resize or setGeometry have no effect but
min/max size and SizePolicy is used instead.