How can i change the placeholderText color in QML TextField

Viewed 1486

I tried using the TextField Styled but there was no effect on the placeholder text ,how do i change the color of placeholderText

1 Answers

TextField has a property placeholderTextColor dedicated to the color:

With Qt Quick Controls 2 (requires at least Qt 5.12):

import QtQuick.Controls 2.5
TextField {
    anchors.fill: parent
    placeholderText: "Here is a place holder"
    placeholderTextColor: "red"
}

With Qt Quick Controls 1:

import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
TextField {
      anchors.fill: parent
      style: TextFieldStyle {
          placeholderTextColor: "red"
      }
      placeholderText: "Here is a place holder"
}
Related