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

QPalette::PlaceholderText color is not followed after setting color in a style sheet

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.5.0 Beta1
    • 6.0.3
    • Widgets: Style Sheets
    • None
    • Apple clang version 12.0.0 (clang-1200.0.32.29)
      MacOS 11.2.3
    • macOS
    • 72a3da3d4d (qt/qtbase/dev) 72a3da3d4d (qt/tqtc-qtbase/dev)

    Description

      I'm finding that the color of the placeholder text cannot be changed once I've set the (for example) QLineEdit's color via a stylesheet (see the code snippet below).

      Running the code below, both the placeholder text and the text the user types into the QLineEdit are blue.

      However, if I comment out the setStyleSheet line below, I find that the placeholder text is green and the text the user types in is white.

       

      QLineEdit *pLine = new QLineEdit;
      pLine->setPlaceholderText("helpful");
      
      pLine->setStyleSheet("QLineEdit {color: rgb(0,0,255);}");
      
      QPalette palette = pLine->palette();
      palette.setColor(QPalette::PlaceholderText, QColor(0,255,0));
      pLine->setPalette(palette);
      

       

       

      Attachments

        Issue Links

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              alargespeaker alargespeaker
              Votes:
              4 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: