Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.9.4
-
None
-
Debian 9
Description
Consider following code:
QLabel label; QPalette pal; pal.setColor(QPalette::WindowText, color); label.setFont(font); label.setPalette(pal); label.setText(text); QGraphicsDropShadowEffect shadowEff; shadowEff.setOffset(2); label.setGraphicsEffect(&shadowEff); QPixmap pixTxt = label.grab(); //label.show(); // calculates label.size() //QPixmap pixTxt = label.grab(QRect(QPoint(0, 0), QSize(label.width()+shadowEff.offset().x(), label.height()+shadowEff.offset().y()))); painter.drawPixmap(QPointF(0, -10), pixTxt);
It paints text onto pixmap which rectangle is auto calculated by QWidget::grab() method.
The rectangle is calculated wrong and the shadow is cropped as seen on image "grab_auto.png".
If rectangle is calculated this way:
//QPixmap pixTxt = label.grab(); label.show(); // calculates label.size() QPixmap pixTxt = label.grab(QRect(QPoint(0, 0), QSize(label.width()+shadowEff.offset().x(), label.height()+shadowEff.offset().y()))); painter.drawPixmap(QPointF(0, -10), pixTxt);
the shadow is not cropped as seen on image "grab_manual.png".