Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Placing a Button at the right edge of Menubar

Placing a Button at the right edge of Menubar

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 3 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I have a QML application which uses ApplicationWindow with a QuickControls2 MenuBar which spans the width of the window. I would like to add a button at the right end side of this menu. This button should control the expansion of a right-hand toolbar. How can this be done?

    1 Reply Last reply
    0
    • IntruderExcluderI Offline
      IntruderExcluderI Offline
      IntruderExcluder
      wrote on last edited by
      #2

      You can set parent for a button like this:

      ApplicationWindow {
          id: window
          width: 320
          height: 260
          visible: true
      
          menuBar: MenuBar {
              Menu {
                  title: qsTr("&File")
                  Action { text: qsTr("&New...") }
                  Action { text: qsTr("&Open...") }
                  Action { text: qsTr("&Save") }
                  Action { text: qsTr("Save &As...") }
                  MenuSeparator { }
                  Action { text: qsTr("&Quit") }
              }
              Menu {
                  title: qsTr("&Edit")
                  Action { text: qsTr("Cu&t") }
                  Action { text: qsTr("&Copy") }
                  Action { text: qsTr("&Paste") }
              }
              Menu {
                  title: qsTr("&Help")
                  Action { text: qsTr("&About") }
              }
      
          }
          ToolButton {
              anchors.right: parent.right
              parent: window.menuBar // Set main menu toolbar as parent for tool button
              text: "⋮"
          }
      }
      
      V 1 Reply Last reply
      4
      • IntruderExcluderI IntruderExcluder

        You can set parent for a button like this:

        ApplicationWindow {
            id: window
            width: 320
            height: 260
            visible: true
        
            menuBar: MenuBar {
                Menu {
                    title: qsTr("&File")
                    Action { text: qsTr("&New...") }
                    Action { text: qsTr("&Open...") }
                    Action { text: qsTr("&Save") }
                    Action { text: qsTr("Save &As...") }
                    MenuSeparator { }
                    Action { text: qsTr("&Quit") }
                }
                Menu {
                    title: qsTr("&Edit")
                    Action { text: qsTr("Cu&t") }
                    Action { text: qsTr("&Copy") }
                    Action { text: qsTr("&Paste") }
                }
                Menu {
                    title: qsTr("&Help")
                    Action { text: qsTr("&About") }
                }
        
            }
            ToolButton {
                anchors.right: parent.right
                parent: window.menuBar // Set main menu toolbar as parent for tool button
                text: "⋮"
            }
        }
        
        V Offline
        V Offline
        Vijaykarthikeyan
        wrote on last edited by
        #3

        @IntruderExcluder thank you..

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved