amlwwalker
amlwwalker

Reputation: 3314

QML TextField setting focus highlight colours

I have a textfield and when I highlight text in it (select All shortcut) the selection colour is blue (default):

enter image description here

TextField {
  id: setDescription
  placeholderText: "no description yet...."
  text: display.description
  font.family: "Helvetica"
  font.pixelSize: 15
  Layout.row: 1
  Layout.column: 1
  Layout.columnSpan: 2
  background: Rectangle {
      radius: 2
      border.color: Theme.gray
      border.width: 1
      height: setDescription.height
  }
  color: Theme.darkGray
  wrapMode: Text.Wrap
  Layout.fillWidth: true
  onEditingFinished: {
    console.log("[detail] patch ", display.id)
  }
}

How do I choose a different selection colour? I can't find anything in the docs that references this?

Thanks

Upvotes: 2

Views: 2188

Answers (1)

mike510a
mike510a

Reputation: 2168

try the property selectionColor property

TextField {
      id: setDescription
      placeholderText: "no description yet...."
      text: display.description
      font.family: "Helvetica"
      font.pixelSize: 15

      background: Rectangle {
          radius: 2
          border.color: Theme.gray
          border.width: 1
          height: setDescription.height
      }
      color: Theme.darkGray
      wrapMode: Text.Wrap

     selectionColor:  "red"
      onEditingFinished: {
        console.log("[detail] patch ", display.id)
      }
    }

Upvotes: 3

Related Questions