QLabel fields and padding profile in Qt

I have a label, and I set both the addition in the stylesheet and the margin with setMargin().

ui->label->setPixmap(redRectWithGreenBorder(80, 40));
ui->label->setStyleSheet("QLabel {border: 1px solid gray;border-radius: 2px;background-color: white;padding: 0px 5px 10px 15px;}");
ui->label->setMargin(5);

But here's what it actually looks like:

enter image description here

Visible fields are 5, 10, 15 and 20 (I checked using the image editor). That is, they are equal to the value of the stylesheet for this side, plus the value margin(), that is, 0 + 5, 5 + 5, 10 + 5, 20 + 5.

However, the documentation says this setMargin():

margin: int This property holds the width of the field.

Fields are the distance between the innermost pixel of a frame and the outermost pixel of content.

The default value is 0.

, , . . - .

: ? , , ?

+4
2

, , QLabel. . margin QLabel - , ; Qt 4.0 ( ). , Qt 4.2.

: , margin, . , 4 . , .

, margin padding - . . QLabel . , . - QLabel. . 4,0 Qt 4.2, .

+3

QLabel QPushButton. QPushButton . "QLabels".

Qt::WA_TransparentForMouseEvents, , QLabel.

, , .

QPushButton . border: 1px solid # 000000; , padding-left 1px... .

0

Source: https://habr.com/ru/post/1545879/


All Articles