Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-68285

QWidget::grab() calculates render rectangle wrong when using QGraphicsDropShadowEffect

    XMLWordPrintable

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".

       

      Attachments

        1. grab_auto.png
          grab_auto.png
          1 kB
        2. grab_manual.png
          grab_manual.png
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            killdaclick Maciej Andrzejewski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes