Results 1 to 9 of 9

Thread: Redirection - Login.qml to Home.qml

  1. #1
    Join Date
    Jul 2016
    Posts
    53
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default Redirection - Login.qml to Home.qml

    Hi,

    I am developing an mobile app in Qt/C++. I had designed the Login page , Now i have to redirect to HomePage.qml.
    How can I achieve that?

    Thanks in advance.

  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: Redirection - Login.qml to Home.qml

    How do you display Login.qml?

    Is it directly instantiated in your main QML file?
    Is it the main QML file?

    Cheers,
    _

  3. #3
    Join Date
    Jul 2016
    Posts
    53
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default Re: Redirection - Login.qml to Home.qml

    Sorry for the delay,

    HomePage.QML will not be the mail QML file.

    What I did:
    Created one qml file called HomePage.Qml, after login successful I have to show the HomePage.qml.

    Thanks in advance

  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: Redirection - Login.qml to Home.qml

    Quote Originally Posted by Mathan View Post
    HomePage.QML will not be the mail QML file.
    Sorry, misunderstanding, this is not what I was asking for.

    Is Login.qml the main QML file? The one you are passing to QQuickView or QQuickWindow?

    Or are you loading a different QML file first that then instantiates a Login object or uses a Loader to load Login.qml?

    Cheers,
    _

  5. #5
    Join Date
    Jul 2016
    Posts
    53
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default How to list the map after user authentication is successful/

    Dear All,

    I am developing the app for mobile devices using Qt5.7/ArcGIS Runtime SDK 100.0.0. I had developed the login.qml and can authenticate the user.

    Query: How to redirect the user from the Login.qml to MapList.qml?
    Ex: Login.qml - User authentication
    MapList.qml - Listing of available maps.

    Once the user authenticated successfully, The user has to view the Maplisting. So the user can select the map and view/download it.

    What is the strategy should be followed?

    If possible some examples or Code snippets

    Thanks for the advance

  6. #6
    Join Date
    Jul 2016
    Posts
    53
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default Re: Redirection - Login.qml to Home.qml

    Sorry for the delay.

    Right now I had kept main.qml as a MAIN and wrote the qml code for the Login [Getting user credential/Validated].
    Now, I have to show the list item which is in ListProduct.qml. So How it can be done?
    Ex: in .Net - Redirect or server.transfer

    Here in Qt, What approach I have to follow?

  7. #7
    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: Redirection - Login.qml to Home.qml

    Quote Originally Posted by Mathan View Post
    Right now I had kept main.qml as a MAIN and wrote the qml code for the Login [Getting user credential/Validated].
    So your main.qml contains the code for login and you don't have a separate Login.qml?

    Maybe it would be better if you posted some code instead of randomly referring to different files.

    Cheers,
    _

  8. #8
    Join Date
    Jul 2016
    Posts
    53
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default Re: Redirection - Login.qml to Home.qml

    Yes, You are right, Login.qml code has to logically seprated, Since I unable to redirect to Login.qml from main.qml, I had implanted the code in main.qml itself.

    According to this code, text field with username and password will be shown, Once the user is authenticated, I setting to load an method.

    Code of main.qml:
    Qt Code:
    1. import QtQuick 2.3
    2. import QtQuick.Controls 1.2
    3. import Esri.QtCPPSearchV4 1.0
    4.  
    5. import QtQuick.Layouts 1.0
    6.  
    7. QtCPPSearchV4 {
    8. id: objQtCPPSearchV4
    9. width: 800
    10. height: 600
    11.  
    12. // add a mapView component
    13. MapView {
    14. anchors.fill: parent
    15. objectName: "mapView"
    16. }
    17.  
    18. Rectangle{
    19. id: idthisLogin
    20. anchors.fill: parent
    21. property bool loginSuccess: false
    22. color: "white"
    23.  
    24. Timer{
    25. id: idinfoTimer
    26. interval: 5000;
    27. running: false;
    28. repeat: false;
    29. onTriggered: {
    30.  
    31. if(idthisLogin.loginSuccess){
    32. idInfoPopUp.visible = true
    33. idthisLogin.visible = false
    34. }else
    35. {
    36.  
    37. idLoginColumn.visible = true
    38. }
    39.  
    40.  
    41. }//onTriggered
    42.  
    43. }//Timer
    44.  
    45. MouseArea{
    46. anchors.bottomMargin: 0
    47. anchors.leftMargin: 1
    48. anchors.rightMargin: -1
    49. anchors.topMargin: 0
    50. anchors.fill:parent
    51. onClicked: {
    52. console.log("Clicked Mouse Area: Login");
    53. }
    54. }
    55.  
    56.  
    57.  
    58. Item {
    59. id: idItemLogin
    60. width: parent.width / 2
    61. anchors.centerIn: parent
    62. anchors.verticalCenterOffset: -parent.height / 4
    63.  
    64. ColumnLayout{
    65. id: idLoginColumn
    66. anchors.fill: parent
    67. anchors.margins: 3
    68. spacing: 3
    69.  
    70. TextField{
    71. id: idUsernameTextField
    72. Layout.fillWidth: true
    73. placeholderText: "UserName"
    74. }
    75.  
    76. TextField{
    77. id: idPasswordTextField
    78. Layout.fillWidth: true
    79. placeholderText: "Password"
    80. }
    81.  
    82. Button{
    83. id: idbtnSubmit
    84. Layout.fillWidth: true
    85. text: "Login"
    86.  
    87. onClicked: {
    88. console.log("ProcessButton: id = ", idUsernameTextField.text)
    89. console.log("ProcessButton: Password = ", idPasswordTextField.text)
    90.  
    91. if(idUsernameTextField.text == "m" && idPasswordTextField.text == "123"){
    92. idthisLogin.loginSuccess = true;
    93. idLoginColumn.visible = false
    94.  
    95. idinfoTimer.start ()
    96. idInfoPopUp.info = qsTr("Login Success!");
    97. idInfoPopUp.visible = true
    98. objQtCPPSearchV4.funcLoadBasemap();
    99.  
    100.  
    101.  
    102.  
    103. }
    104. else
    105. {
    106. idthisLogin.loginSuccess = false
    107. idInfoPopUp.info = qsTr("Login Failed!");
    108. idLoginColumn.visible = true
    109.  
    110.  
    111. }
    112.  
    113. idUsernameTextField.text = ""
    114. idPasswordTextField.text = ""
    115.  
    116.  
    117. }
    118. }
    119.  
    120. }//ColumnLayout
    121.  
    122. Rectangle{
    123. id: idInfoPopUp
    124. color: "red"
    125. anchors.fill: parent
    126. property string info: qstr("Login");
    127. visible: false
    128.  
    129. Text {
    130. width: 318
    131. height: 65
    132.  
    133. text: idInfoPopUp.info
    134. anchors.verticalCenterOffset: -5
    135. anchors.horizontalCenterOffset: 0
    136. anchors.centerIn: parent;
    137. }
    138.  
    139. }
    140.  
    141. }//Item
    142.  
    143.  
    144. }//Rectangle
    145.  
    146.  
    147.  
    148.  
    149. /*Function for the JavaScript*/
    150. function funcLoadBasemap()
    151. {
    152. objQtCPPSearchV4.metLoadBaseMap()
    153.  
    154. }
    155.  
    156. }//QtCPPSearchV4
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 3rd August 2016 at 15:36. Reason: missing [code] tags

  9. #9
    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: Redirection - Login.qml to Home.qml

    There are two ways to change the content:

    1) set one item visible while setting the old one invisble. you do that already.
    2) Using a Loader and changing its source or sourceComponent

    For your code, instead of the Rectangle with the id "idthisLogin" you could have a Loader will the main item

    Qt Code:
    1. QtCPPSearchV4 {
    2. Loader {
    3. anchors.fill: parent
    4.  
    5. property bool loginSuccess: false
    6.  
    7. source: loginSuccess ? "MainView.qml" : "Login.qml"
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 
    When the loginSuccess property changes, then the Loader's content changes.

    Cheers,
    _

Similar Threads

  1. Redirection Url in QWebview
    By zgulser in forum Qt Programming
    Replies: 2
    Last Post: 11th April 2012, 18:57
  2. QNetworkAccessManager and http redirection
    By grayfox in forum Qt Programming
    Replies: 5
    Last Post: 8th July 2011, 18:24

Tags for this Thread

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.