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

When QML TextEdit is readOnly, persistentSelection has no effect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.13.1, 5.14.0 Alpha
    • 5.5.1
    • None
    • Precompiled Qt 5.5.1 for win32 (using mingw)
    • 1d0f808c7dc708f5ec8093f09f332615b94f4318 (qt/qtdeclarative/dev)

    Description

      I'm trying to use a TextEdit to have some selectable (selectByMouse set to true) text on, but I don't want the user to be able to change it, so I have set readOnly to true.
      The problem is that I have several of these TextEdit's, and I don't want the selection state to persist when selecting text from one of the other components, so I set persistentSelection to false hoping that would do it, but it doesn't seem to work.
      However, if I set readOnly to false the persistentSelection property works as intended.

      I'm not sure if that is intended behaviour or not, and if I perhaps should be using some other component that will work better.

      import QtQuick 2.12
      import QtQuick.Window 2.12
      
      Window {
          id: window
          width: 640
          height: 480
          visible: true
          title: "QTBUG-50587"
      
          readonly property bool readOnly: true
      
          Row {
              Column {
                  Text {
                      text: "TextInput"
                      anchors.horizontalCenter: parent.horizontalCenter
                  }
      
                  TextInput {
                      text: "readOnly: " + readOnly
                      padding: 12
                      readOnly: window.readOnly
                      selectByMouse: true
      
                      Rectangle {
                          anchors.fill: parent
                          color: "transparent"
                          border.color: "darkorange"
                      }
                  }
                  TextInput {
                      text: "readOnly: " + readOnly
                      padding: 12
                      readOnly: window.readOnly
                      selectByMouse: true
      
                      Rectangle {
                          anchors.fill: parent
                          color: "transparent"
                          border.color: "darkorange"
                      }
                  }
              }
      
              Column {
                  Text {
                      text: "TextEdit"
                      anchors.horizontalCenter: parent.horizontalCenter
                  }
      
                  TextEdit {
                      text: "readOnly: " + readOnly
                      padding: 12
                      readOnly: window.readOnly
                      selectByMouse: true
      
                      Rectangle {
                          anchors.fill: parent
                          color: "transparent"
                          border.color: "darkorange"
                      }
                  }
                  TextEdit {
                      text: "readOnly: " + readOnly
                      padding: 12
                      readOnly: window.readOnly
                      selectByMouse: true
      
                      Rectangle {
                          anchors.fill: parent
                          color: "transparent"
                          border.color: "darkorange"
                      }
                  }
              }
          }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            homersp Mathias
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes