简体   繁体   中英

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):

在此处输入图片说明

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

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)
      }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM