If I have a label that has a margin that is set using setMargin(), then I can use margin() to get the value.
But when if I set the padding using a style sheet?
ui->label->setStyleSheet("QLabel {padding: 0px 5px 10px 15px;}");
How can I get the values programmatically? Is there a function that will give me the value for a given property in the style sheet? Is there a function like ui->label()->styleSheet->getProperty("padding:left")?
I've not found any way to give all properties. I think it doesn't exist for architectural reasons. But you can take most of it from QWidget substrucrutes. For example you may take background-color from palette().color(QPalette::Window). If you want to supply qss background in your QWidget with overridden paint event you can do it this way:
void PulseChart::paintEvent(QPaintEvent*)
{
QPainter p{this};
p.fillRect(QRect{QPoint{0,0}, this->size()}, palette().color(QPalette::Window));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With