Results 1 to 15 of 15

Thread: Keys.onEnterPressed

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

    Default Keys.onEnterPressed

    Hii everyone,

    I have a login page (username + password), I want when I click on the button [B] Enter [/ B] after typing the password --> Log in as pressing Button Log in : 1.png

    code Button Log in :
    Qt Code:
    1. Rectangle{
    2. property color previousColor: "transparent"
    3. id: rectangle1
    4. ...
    5. Text {
    6. id: txtLogin
    7. text: qsTr("LOG IN")
    8. ...
    9. }
    10. MouseArea{
    11. id: mouse
    12. anchors.fill: parent
    13. onClicked: {
    14. if(change.text=="USER")
    15. {
    16. if((textinputmod1.txt=="USER")&&(textinputmod2.txt=="1234"))
    17. {
    18. userPage.visible=true
    19. }
    20. else{
    21. winIncId.visible= true
    22. }
    23. textinputmod1.txt= ""
    24. textinputmod2.txt= ""
    25. textinputmod1.focus=true
    26. }
    27. ...
    28. }
    29. }
    30. }
    To copy to clipboard, switch view to plain text mode 

    code TextInput of password:
    Qt Code:
    1. TextInputMod {
    2. id: textinputmod2
    3. textinput: "Password"
    4. mode: TextInput.Password
    5. ...
    6.  
    7.  
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,

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

    Default Re: Keys.onEnterPressed

    If TextInputMod is an extended TextInput, you just need to react to the accepted() signal.

    No need for a mouse area

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Binary01 (9th February 2016)

  4. #3
    Join Date
    Dec 2015
    Posts
    35
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Keys.onEnterPressed

    Hiii,

    Create a function then call it in mouseArea(onClicked) and TextInputMod (e.g)

    Qt Code:
    1. MouseArea{
    2. id: mouse
    3. anchors.fill: parent
    4. function key() {
    5. if((textinputmod1.txt=="USER")&&(textinputmod2.txt=="1234"))
    6. {
    7. userPage.visible=true
    8. }
    9. else{
    10. winIncId.visible= true
    11. }
    12. textinputmod1.txt= ""
    13. textinputmod2.txt= ""
    14. textinputmod1.focus=true
    15. }
    16. onClicked: {
    17. if(change.text=="USER")
    18. {
    19. key()
    20. }
    21. ...
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 

    In TextInputMod :
    Qt Code:
    1. Keys.onEnterPressed: {
    2. if(change.text=="USER") mouse.key()
    To copy to clipboard, switch view to plain text mode 

    Cheers,

  5. The following user says thank you to RegMe for this useful post:

    Binary01 (9th February 2016)

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

    Default Re: Keys.onEnterPressed

    Hiii thanks for yr reply

    I have an other problem, I want when I login true (use name + password = true) open the page user (userPage) and close automatically page of Authentification : Attachment 11685

    I use page user (User) as instance in page (Authentification)

    Qt Code:
    1. Window{
    2. id: root
    3. minimumWidth: 1200
    4. minimumHeight: 600
    5. title: "Authentification
    6.  
    7. ...
    8.  
    9. User{
    10. id: userPage
    11. visible: false
    12.  
    13. }
    14.  
    15. ...
    16. "
    To copy to clipboard, switch view to plain text mode 
    There is a way to close Authentification page when login true ??
    I used root.close(); but both the pages close

    Cheers

  7. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Keys.onEnterPressed

    What is User?
    A Window? An Item?

    Is the authentication also a child of your "root" window?

    Cheers,
    _

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

    Default Re: Keys.onEnterPressed

    Authentification.qml
    Qt Code:
    1. Window{
    2. id: root
    3. minimumWidth: 1200
    4. minimumHeight: 600
    5. title: "Authentification"
    6.  
    7. ...
    8.  
    9. User{
    10. id: userPage
    11. visible: false
    12.  
    13. }
    14.  
    15. ...
    To copy to clipboard, switch view to plain text mode 

    User.qml
    Qt Code:
    1. Window {
    2. id: user
    3. width: 1200
    4. height: 700
    5. minimumWidth: 1100
    6. color: base
    7.  
    8. ...
    To copy to clipboard, switch view to plain text mode 

    User is an instance of Authentification

    is there a way to close authentication when I Log = true ( open User.qml and close Authentification.qml) ?

    Cheers,
    Last edited by Binary01; 9th February 2016 at 17:14.

  9. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Keys.onEnterPressed

    I am trying to understand your architecture.

    Somewhere you write about "pages", which makes it sound like you have one window with different contents.
    But you seem to have at least two windows.

    Cheers,
    _

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

    Default Re: Keys.onEnterPressed

    Yes, Authentication.qml is a Window and User.qml is also a Window

    I called [B]User[B] in Authentication.qml when login is TRUE

    Authentification.qml :
    Qt Code:
    1. ...
    2. MouseArea{
    3. id: mouse
    4. anchors.fill: parent
    5. function key() {
    6. if((textinputmod1.txt=="USER")&&(textinputmod2.txt=="1234"))
    7. {
    8. userPage.visible=true
    9. ( userPage = ID of USER --- User { id: userPage, visible: false } )
    10. }
    11. else{
    12. winIncId.visible= true
    13. }
    14. textinputmod1.txt= ""
    15. textinputmod2.txt= ""
    16. textinputmod1.focus=true
    17. }
    18. onClicked: {
    19. if(change.text=="USER")
    20. {
    21. key()
    22. }
    23. ...
    24. }
    25. }
    26. .....
    27. User{
    28. id: userPage
    29. visible: false
    30.  
    31. }
    32.  
    33. }
    To copy to clipboard, switch view to plain text mode 

    So a window (Authentification) calls an other window (User)

    Cheers,


    Added after 1 8 minutes:


    Is there an other way to call User.qml when login = TRUE and close Authentification.qml ?
    Last edited by Binary01; 9th February 2016 at 20:57.

  11. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Keys.onEnterPressed

    Logically, isn't Authentication the sub window, that you only need to show temporarily, while User is the main window which stays around?

    Cheers,
    _

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

    Default Re: Keys.onEnterPressed

    In fact, I have 3 windows:
    Authentication (Authentification.qml)
    User (User.qml)
    Admin (Admin.qml)
    See the next image : 3.jpg

    Yes, I need to show Authentification first temporarily to login next show User (if login=true) or Admin
    Like the Authentication in Window PC when we have more than one session.

    I thing that the logic that I used (call User or Admin inside Authentication isn't good)

    Authentification.qml:
    Qt Code:
    1. Window{
    2. id: root
    3. minimumWidth: 1200
    4. minimumHeight: 600
    5. title: "Authentification"
    6.  
    7. ...
    8.  
    9. User{
    10. id: userPage
    11. visible: false
    12.  
    13. }
    14.  
    15. Admin{
    16. id: adm
    17. visible: false
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 

    Have you any idea or an other suggestion ?

    Cheers

  13. #11
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Keys.onEnterPressed

    Hmm, I am still not sure I understand the architecture you are going for but you could try some of these

    1) Use one window and change its contents
    2) Use a non visible root element and have it hold the two windows side-by-side
    3) Provide a function implemented in C++ to load a different window into the engine

    Cheers,
    _

  14. #12
    Join Date
    Dec 2015
    Posts
    35
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Keys.onEnterPressed

    Try to make Authentication : visible = false when the log in = true in the function key()

    Qt Code:
    1. MouseArea{
    2. id: mouse
    3. anchors.fill: parent
    4. function key() {
    5. if((textinputmod1.txt=="USER")&&(textinputmod2.txt=="1234"))
    6. {
    7. userPage.visible=true
    8.  
    9. // make root invisible
    10. root.visible = false
    11.  
    12. }
    13. else{
    14. winIncId.visible= true
    15. }
    16. textinputmod1.txt= ""
    17. textinputmod2.txt= ""
    18. textinputmod1.focus=true
    19. }
    20. onClicked: {
    21. if(change.text=="USER")
    22. {
    23. key()
    24. }
    25. ...
    26. }
    27. }
    To copy to clipboard, switch view to plain text mode 
    Cheers,

  15. The following user says thank you to RegMe for this useful post:

    Binary01 (17th February 2016)

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

    Default Re: Keys.onEnterPressed

    Great, It works

    Making visible = false ==== close the window/rectangle ?
    Is there an other way better than making visible=false?

    Cheers,

  17. #14
    Join Date
    Dec 2015
    Location
    Austria
    Posts
    23
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: Keys.onEnterPressed

    Well you could use only one window with a loader or stackview control instead of having 3 different Windows.
    This would be a better way for a mobile solution. But your login window Looks like it is used on a Desktop.

  18. #15
    Join Date
    Dec 2015
    Posts
    35
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Keys.onEnterPressed

    You can use Stackview, it's better,
    All in One window

    Qt Code:
    1. Window{
    2. id: root
    3. minimumWidth: 1200
    4. minimumHeight: 600
    5. title: "Authentification"
    6.  
    7. ...
    8.  
    9. StackView{
    10. delegate: StackViewDelegate {
    11. ...
    12.  
    13. Component {
    14. id: pageAdmin
    15. Admin{
    16. }
    17. }
    18. Component {
    19. id: pageUser
    20. User{
    21. }
    22. }
    23.  
    24. ...
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QMap, keys()
    By mugi in forum Newbie
    Replies: 2
    Last Post: 28th August 2012, 12:37
  2. Shortcut keys??
    By Zingam in forum Qt Quick
    Replies: 1
    Last Post: 20th July 2011, 09:53
  3. QtableWidget and hot keys
    By sawerset in forum Qt Programming
    Replies: 1
    Last Post: 8th December 2008, 20:29
  4. How to identify Num pad keys
    By sanjayshelke in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2008, 18:43
  5. Using Short cut keys
    By joseph in forum Qt Programming
    Replies: 14
    Last Post: 18th March 2008, 20:34

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.