Results 1 to 6 of 6

Thread: problem: how to navigate to different pages using qt quick

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2015
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows Android

    Question problem: how to navigate to different pages using qt quick

    this is my gui code can anyone help me how to navigate to different pages on button click for ex: if i click on login page thaan login page display and if click on register button than registration page shoul display


    Qt Code:
    1. //registration.qml
    2.  
    3. import QtQuick.Controls 1.2
    4. import QtQuick.Controls.Private 1.0
    5. import QtQuick.Controls.Styles 1.1
    6. import QtQuick 2.4
    7. import QtQuick.Window 2.2
    8. import QtQuick.Layouts 1.1
    9. import QtQuick.Dialogs 1.2
    10.  
    11.  
    12.  
    13. Window {
    14. visible: true
    15. id: window1
    16. color:"white"
    17.  
    18. Image {
    19. id: img
    20. width:540
    21. height: 960
    22. source: "qrc:/registration.png"
    23. }
    24.  
    25.  
    26.  
    27. Item {
    28.  
    29. id:item1
    30. anchors.horizontalCenter: parent.horizontalCenter
    31. anchors.verticalCenter: parent.verticalCenter
    32.  
    33. width: 570; height: 170
    34. anchors.verticalCenterOffset: 117
    35. anchors.horizontalCenterOffset: 7
    36.  
    37.  
    38. Column {
    39. width: 360
    40. height: 221
    41. anchors.verticalCenterOffset: -115
    42. anchors.horizontalCenterOffset: -5
    43. anchors.horizontalCenter: parent.horizontalCenter
    44. anchors.verticalCenter: parent.verticalCenter
    45.  
    46. spacing: 20
    47.  
    48.  
    49.  
    50. TextField {
    51. placeholderText:"Address"
    52. style: TextFieldStyle
    53. {
    54. textColor: "black"
    55. background: Rectangle {
    56. radius: 2
    57. implicitWidth: 400
    58. implicitHeight: 53
    59. border.color: "#333"
    60. border.width: 1
    61. }
    62. }
    63. }
    64.  
    65.  
    66. TextField {
    67. placeholderText:"Username"
    68. style: TextFieldStyle
    69. {
    70. textColor: "black"
    71. background: Rectangle {
    72. radius: 2
    73. implicitWidth: 350
    74. implicitHeight: 53
    75. border.color: "#333"
    76. border.width: 1
    77. }
    78. }
    79. }
    80.  
    81.  
    82. TextField {
    83. placeholderText:"Phone number"
    84. style: TextFieldStyle
    85. {
    86. textColor: "black"
    87. background: Rectangle {
    88. radius: 2
    89. implicitWidth: 350
    90. implicitHeight: 53
    91. border.color: "#333"
    92. border.width: 1
    93. }
    94. }
    95. }
    96.  
    97. TextField {
    98. echoMode: TextInput.Password
    99. placeholderText:"Password"
    100. style: TextFieldStyle
    101. {
    102. textColor: "black"
    103. background: Rectangle {
    104. radius: 2
    105. implicitWidth: 350
    106. implicitHeight: 53
    107. border.color: "#333"
    108. border.width: 1
    109. }
    110. }
    111. }
    112.  
    113.  
    114. Button{
    115.  
    116.  
    117. id: btn
    118. text:"Submit"
    119. style: ButtonStyle{
    120. background: Rectangle {
    121. implicitWidth: 350
    122. implicitHeight: 53
    123. radius: 10.0
    124. border.width: control.activeFocus ? 2 : 1
    125. border.color: "#888"
    126. gradient: Gradient {
    127. GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" }
    128. GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" }
    129. }
    130. color:"gold"
    131. ColorAnimation on color { to: "lightblue"; duration: 3000 }
    132.  
    133. }
    134. }
    135. }
    136. }
    137.  
    138. }
    139. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 1st November 2015 at 21:31. Reason: missing [code] tags

  2. #2
    Join Date
    Aug 2015
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: problem: how to navigate to different pages using qt quick

    Which code is missing can u correct it or can u tell me which code should i use

  3. #3
    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: problem: how to navigate to different pages using qt quick

    Make the visible property of the two windows false or do not set it at all.
    Add one instance each to the welcome.qml

    Instead of emitting a signal, call show() on the respective window.

    Cheers,
    _

  4. #4
    Join Date
    Aug 2015
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: problem: how to navigate to different pages using qt quick

    Thnx
    can u tell me how to create instance


    Added after 5 minutes:


    Can u tell me how to store data in sqlite on button click in qt quick with example
    Last edited by Yogesh soni; 4th November 2015 at 14:56.

  5. #5
    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: problem: how to navigate to different pages using qt quick

    Quote Originally Posted by Yogesh soni View Post
    Thnx
    can u tell me how to create instance
    The easiest way is to use filenames starting with an uppercase letter for the two Windows and then just using that file name in your main QML like if it where an element type.

    E.g. if you rename registration.qml to Registration.qml, you can instantiate an object of Registration like this in welcome.qml

    Qt Code:
    1. Registration {
    2. id: registrationWindow
    3. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

Similar Threads

  1. Replies: 3
    Last Post: 5th July 2016, 16:13
  2. problem with qt quick designer
    By davod in forum Qt Tools
    Replies: 0
    Last Post: 13th March 2014, 19:38
  3. Replies: 1
    Last Post: 31st August 2013, 06:30
  4. Problem with building Qt quick application
    By Taspa in forum Qt Quick
    Replies: 2
    Last Post: 30th November 2010, 23:03
  5. Replies: 2
    Last Post: 17th May 2009, 21:58

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
  •  
Qt is a trademark of The Qt Company.