Results 1 to 2 of 2

Thread: Qml Android open View from MenuItem

  1. #1
    Join Date
    Feb 2018
    Posts
    21
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Qml Android open View from MenuItem

    Good Morning, I have to open a window by cliking in the menu how I do?
    catturaMenu.jpg

    this is My QML:

    Qt Code:
    1. import QtQuick 2.0
    2. import QtQuick.Controls 2.5
    3. import QtQuick.Layouts 1.12
    4.  
    5. ApplicationWindow {
    6. id: window
    7. width: 500
    8. height: 500
    9.  
    10.  
    11.  
    12. visible:true
    13.  
    14. Rectangle {
    15. id: rectangle
    16. color: "#212126"
    17. anchors.fill: parent
    18. }
    19.  
    20.  
    21. header: ToolBar {
    22.  
    23. background:Rectangle
    24. {
    25. implicitHeight: 40
    26. color: "beige"
    27. }
    28.  
    29.  
    30.  
    31. RowLayout {
    32. anchors.fill: parent
    33. ToolButton {
    34. text: qsTr("‹")
    35. onClicked: stackView.pop()
    36. }
    37. Label {
    38. text: "App Paolo"
    39. elide: Label.ElideRight
    40. horizontalAlignment: Qt.AlignHCenter
    41. verticalAlignment: Qt.AlignVCenter
    42. Layout.fillWidth: true
    43. }
    44. ToolButton {
    45. text: qsTr("?")
    46. onClicked: {
    47. menu.x = (window.width - menu.width) / 1
    48. menu.y = 10
    49. menu.open()}
    50. }
    51. }
    52. }
    53.  
    54. ListModel {
    55. id: pageModel
    56. ListElement {
    57. title: "Riparazioni"
    58. page: "Riparazioni.qml"
    59. }
    60. ListElement {
    61. title: "Magazzino"
    62. page: "Magazzino.qml"
    63. }
    64. }
    65. StackView {
    66. id: stackView
    67. anchors.fill: parent
    68. // Implements back key navigation
    69. focus: true
    70. // //Keys.onReleased: if (event.key === Qt.Key_Back && stackView.depth > 1) {
    71. // stackView.pop();
    72. // event.accepted = true;
    73. // }
    74.  
    75. initialItem: Item {
    76. width: parent.width
    77. height: parent.height
    78. ListView {
    79. model: pageModel
    80. anchors.fill: parent
    81. delegate: AndroidDelegate {
    82. text: title
    83. onClicked: stackView.push(Qt.resolvedUrl(page))
    84. }
    85. }
    86. }
    87. }
    88. StackView {
    89. id: stack
    90. anchors.fill: parent
    91. }
    92.  
    93. Menu {
    94. id: menu
    95.  
    96. MenuItem{
    97. text: "Settings"
    98. onClicked: { //Open View help me tank
    99.  
    100.  
    101. }
    102.  
    103.  
    104. }
    105. }
    106.  
    107.  
    108.  
    109.  
    110.  
    111. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2018
    Posts
    21
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qml Android open View from MenuItem

    I answer myself I did so and it works:

    MenuItem{
    text: "Settings"
    onClicked: {

    stackView.push("Settings.qml")



    }

Similar Threads

  1. Android - Open file with QFile
    By lqsa in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 19th March 2016, 09:14
  2. How to open a new window in Android?
    By tarod in forum Qt Quick
    Replies: 1
    Last Post: 5th September 2014, 16:24
  3. bad view with QtQuick 2.0 in android divce
    By solook in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 19th December 2013, 12:50
  4. How to get Qmenu menuitem text
    By jins in forum Newbie
    Replies: 1
    Last Post: 5th December 2010, 17:56
  5. Focus in QT MenuItem
    By sk.qt in forum Newbie
    Replies: 2
    Last Post: 20th October 2010, 11:02

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.