Results 1 to 4 of 4

Thread: Focus

  1. #1
    Join Date
    Jan 2016
    Posts
    54
    Thanks
    7
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Focus

    Hi everyOne

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

    Authentication.qml
    Qt Code:
    1. Window{
    2. id: root
    3. ...
    4.  
    5. TextInputMod{
    6. id: textinputmod1
    7. focus: true
    8. ... }
    9.  
    10. TextInputMod{
    11. id: textinputmod
    12. ...}
    13.  
    14. MouseArea{
    15. ...
    16. onClicked: {
    17. if(change.text=="ADMIN") stackId.push(pageAdmin)
    18. if(change.text=="USER") stackId.push(pageUser)
    19. }
    20.  
    21.  
    22. StackView{
    23. id: stackId
    24. ...
    25.  
    26. Component {
    27. id: pageAdmin
    28. Admin{
    29. }
    30. }
    31. Component {
    32. id: pageUser
    33. User{
    34. }
    35. }
    To copy to clipboard, switch view to plain text mode 

    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,

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Focus

    What does "focus don't work" mean in this context?

    Have you set the active focus after pushing the page?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2016
    Posts
    54
    Thanks
    7
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Focus

    Quote Originally Posted by anda_skoa View Post
    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
    Qt Code:
    1. Window{
    2. id: root
    3. ...
    4.  
    5. TextInputMod{
    6. id: textinputmod1
    7. focus: true // FOCUS OK
    8. ... }
    9.  
    10. TextInputMod{
    11. id: textinputmod
    12. ...}
    13.  
    14. MouseArea{
    15. ...
    16. onClicked: {
    17. if(change.text=="ADMIN") stackId.push(pageAdmin)
    18. if(change.text=="USER") stackId.push(pageUser)
    19. }
    20.  
    21.  
    22. StackView{
    23. id: stackId
    24. ...
    25.  
    26. Component {
    27. id: pageAdmin
    28. Admin{
    29. }
    30. }
    31. Component {
    32. id: pageUser
    33. User{
    34. }
    35. }
    To copy to clipboard, switch view to plain text mode 

    When I push User or Admin.qml ---> TextInputMod doesn't focus
    User.qml
    Qt Code:
    1. TextInputMod{
    2. id: input1
    3. width: 167
    4. height: 30
    5. focus: true // FOCUS FAILS
    6. KeyNavigation.tab: input2
    7. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Focus

    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,
    _

Similar Threads

  1. Focus Out problem
    By Chirag in forum Qt Programming
    Replies: 2
    Last Post: 2nd May 2011, 07:32
  2. Window focus issues (How to force focus to a window?)
    By montylee in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2009, 02:00
  3. focus
    By hgedek in forum Newbie
    Replies: 3
    Last Post: 25th December 2007, 20:14
  4. Focus issues / Setting multiple focus
    By ComputerPhreak in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2007, 07:09
  5. Focus Help please
    By munna in forum Qt Programming
    Replies: 3
    Last Post: 15th November 2006, 19:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.