UPD:
I write this method for drawing, looks good
{
QLabel::paintEvent(event);
QPainter painter (this);
painter.setPen(Qt::green);
painter.setBrush(palette().windowText());
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
painter.setFont(font());
QRect font_rect = painter.fontMetrics().boundingRect(text());
QRect label_rect = contentsRect();
label_rect.adjust(margin(), margin(), -margin(), -margin());
int dx = label_rect.width() - font_rect.width();
int dy = label_rect.height() - font_rect.height();
int x = 0;
int y = 0;
if (alignment() & Qt::AlignLeft) x = label_rect.left();
else if (alignment() & Qt::AlignHCenter) x = label_rect.left() + dx / 2;
else if (alignment() & Qt::AlignRight) x = label_rect.right() - font_rect.width();
if (alignment() & Qt::AlignTop) y = label_rect.top() + font_rect.height();
else if (alignment() & Qt::AlignVCenter) y = label_rect.top() + dy / 2;
else if (alignment() & Qt::AlignBottom) y = label_rect.bottom();
QPainterPath path;
path.addText(x, y, font(), text());
painter.fillPath(path, palette().windowText());
painter.strokePath(path, QPen(QColor(255, 0, 0, 50), 2));
}
[image: c4d954bb-bb48-4afc-ba4d-b461172f0f61.png]
But i still dont understand the difference btw native paint event and my own