PDA

View Full Version : Focus



Binary01
2nd March 2016, 15:07
Hi everyOne

I have a mainWindow : Authentication.qml that contains an instance of User.qml and Admin.qml

Authentication.qml

Window{
id: root
...

TextInputMod{
id: textinputmod1
focus: true
... }

TextInputMod{
id: textinputmod
...}

MouseArea{
...
onClicked: {
if(change.text=="ADMIN") stackId.push(pageAdmin)
if(change.text=="USER") stackId.push(pageUser)
}


StackView{
id: stackId
...

Component {
id: pageAdmin
Admin{
}
}
Component {
id: pageUser
User{
}
}

Authentication.qml contains a TextInputMod (custom model) : TextInputMod{ focus: true ... } ---> focus works well
but for User.qml and Admin.qml that contain also a TextInputMod : TextInputMod{ focus: true ... } ---> focus don't work

Why? Because stackView !!!
Any solution?

Cheers,

anda_skoa
4th March 2016, 14:13
What does "focus don't work" mean in this context?

Have you set the active focus after pushing the page?

Cheers,
_

Binary01
4th March 2016, 19:47
What does "focus don't work" mean in this context?
_

TextInputMod doesn't focus, I want to focus It when I push pageUser or pageAdmin


All Authentication.qml, User.qml and Admin.qml contain some TextInputMod
I want to focus the 1st TextInputMod in each .qml

Authentication.qml

Window{
id: root
...

TextInputMod{
id: textinputmod1
focus: true // FOCUS OK
... }

TextInputMod{
id: textinputmod
...}

MouseArea{
...
onClicked: {
if(change.text=="ADMIN") stackId.push(pageAdmin)
if(change.text=="USER") stackId.push(pageUser)
}


StackView{
id: stackId
...

Component {
id: pageAdmin
Admin{
}
}
Component {
id: pageUser
User{
}
}

When I push User or Admin.qml ---> TextInputMod doesn't focus
User.qml

TextInputMod{
id: input1
width: 167
height: 30
focus: true // FOCUS FAILS
KeyNavigation.tab: input2
}

Cheers,

anda_skoa
4th March 2016, 20:04
There is already an element with focus, if you want the focus to mode you need to do that, it won't do that automagically.

E.g. call forceActiveFocus() in Admin and User in Component.onCompleted

Cheers,
_