ARTICLE AD BOX
Problem
When using QPlainTextEdit with QSS styling that includes padding and border-radius, the placeholder text does not disappear when the user starts typing. The typed text and the placeholder text render simultaneously, overlapping each other.
This does not happen with QLineEdit using the same QSS rules — only QPlainTextEdit is affected.
Environment
Qt version: 6.10.1
OS: Windows 11
Compiler: MSVC 2022
Minimal Reproducible Example
main.cpp
cpp #include <QApplication> #include <QDialog> #include <QFormLayout> #include <QLineEdit> #include <QPlainTextEdit> #include <QVBoxLayout> int main(int argc, char* argv[]) { QApplication app(argc, argv); // Global stylesheet app.setStyleSheet(R"( QLineEdit, QPlainTextEdit { background-color: #f0f4f8; border: 1px solid #d0d5dd; border-radius: 10px; padding: 8px 12px; color: #1a1a2e; font-size: 14px; } QLineEdit:focus, QPlainTextEdit:focus { border: 1px solid #5b9bd5; } )"); QDialog dialog; dialog.setWindowTitle("QPlainTextEdit Placeholder Bug"); dialog.setMinimumWidth(400); QFormLayout* form = new QFormLayout(&dialog); // QLineEdit — placeholder works correctly QLineEdit* lineEdit = new QLineEdit; lineEdit->setPlaceholderText("This placeholder disappears correctly"); form->addRow("QLineEdit:", lineEdit); // QPlainTextEdit — placeholder does NOT disappear when typing QPlainTextEdit* plainEdit = new QPlainTextEdit; plainEdit->setPlaceholderText("This placeholder stays visible when typing!"); plainEdit->setFixedHeight(80); form->addRow("QPlainTextEdit:", plainEdit); dialog.show(); return app.exec(); }Observed Behavior
Launch the application
Click on the QPlainTextEdit field and start typing.
The placeholder text remains visible, overlapping with the typed text
The QLineEdit above works perfectly — its placeholder disappears as expected.
Expected Behavior
The placeholder text should disappear as soon as the user starts typing, just like QLineEdit.
Question
Is there a clean workaround for this issue that preserves both the visual padding and correct placeholder behavior? Or should this be reported as a Qt bug?
