[Qt-qml] Components, loaders, and focus scope
mathias.malmqvist at nokia.com
mathias.malmqvist at nokia.com
Thu Dec 16 15:13:43 CET 2010
Hi,
Can anyone suggest why the code below doesn't work?
Clicking on the text input components one at a time should move focus between them, but nothing happens.
I've read the documentation here http://doc.qt.nokia.com/4.7/qdeclarativefocus.html
but no change I've made to the code below has made it work.
However if I comment out the two last lines in the the textInputComponent (activeFocusOnPress and MouseArea) then it does work.
Unfortunately this is not an option in my case. Is this due to a bug?
Any suggestions appreciated!
Thanks!
import QtQuick 1.0
Rectangle {
width: 800
height: 480
Loader {
x: 100; y: 100
sourceComponent: textInputComponent
}
Loader {
x: 100; y: 200
sourceComponent: textInputComponent
}
Loader {
x: 100; y: 300
sourceComponent: textInputComponent
}
Component {
id: textInputComponent
TextInput {
width: 200
height: 20
Rectangle { color: parent.activeFocus ? "green" : "red"; anchors.fill: parent; z: -1 }
activeFocusOnPress: false
MouseArea { anchors.fill: parent; onClicked: parent.focus = true }
}
}
}
Cheers
Mathias
More information about the Qt-qml
mailing list