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

QLineEdit ignores stylesheet and palette when grabbed

    XMLWordPrintable

Details

    Description

      On Windows 8 and 8.1, the background of QLineEdit controls is drawn using the default background color when the widget is grabbed (QWidget::grab() and QPixmap::grabWidget()).
      Setting the background color via palette or stylesheet does not work.

      Example
      QLineEdit lineEdit;
      QPalette palette = lineEdit.palette();
      palette.setColor(QPalette::Window, QColor(Qt::red));
      palette.setColor(QPalette::Base, QColor(Qt::red));
      lineEdit.setPalette(palette);
      lineEdit.setStyleSheet("background-color: red;");
      QPixmap pix = lineEdit.grab();
      

      I identified the bug when drawing an item delegate (test project attached).
      It's perhaps linked to the bug QTBUG-40634, but it is not exactly identical since the background here is never drawn using the palette/stylesheet set, unlike the other bug where it is blinking when the QLineEdit is hovered.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sletta Gunnar Sletta
            greisby Greisberger Christophe
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes