[Qt-qml] [QML] fail to selectAll in TextInput

Nevala Samuel Samuel.Nevala at digia.com
Fri Jun 17 06:11:19 CEST 2011


Hi,

Active focus is on rectangle. Try 
...
    height: 400
    MouseArea {
      anchors.fill: parent
      onClicked: {
        textinput.forceActiveFocus();
      }
    }
...

Samuel Nevala
________________________________________
Lähettäjä: qt-qml-bounces+samuel.nevala=digia.com at qt.nokia.com [qt-qml-bounces+samuel.nevala=digia.com at qt.nokia.com] käyttäjän Miao, Qiankun [qiankun.miao at intel.com] puolesta
Lähetetty: 16. kesäkuuta 2011 16:55
Vastaanottaja: qt-qml at trolltech.com; qt-qml at qt.nokia.com
Aihe: [Qt-qml] [QML] fail to selectAll in TextInput

Hi, there

I met some issue when I use TextInput. I tried to selectAll() when activefocus is true and unselectAll when activefocus is false. But it doesn’t work. See following code. Is there a method to implement my requirement?

import Qt 4.7
Rectangle {
    id: rectangle
    width: 600
    height: 400
    MouseArea {
      anchors.fill: parent
      onClicked: {
        rectangle.forceActiveFocus();
      }
    }
    TextInput {
        anchors.centerIn: parent
        id: textinput
        text: "Hello,\n World!"
        cursorVisible: true
        selectByMouse: true
        selectedTextColor: "yellow"
        selectionColor: "royalblue"
        width: parent.width/2
        height: parent.height/2
        onActiveFocusChanged: {
          if (activeFocus == true) {
            selectAll();
          }
          else {
            select(0,0);
          }
        }
    }
}


More information about the Qt-qml mailing list