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. How to make this menu ?
Forum Updated to NodeBB v4.3 + New Features

How to make this menu ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 4 Posters 530 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello, I want to create a submenu like in the photos. How can I show the active menu as in the photo?

    alt text

    alt text

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      There is nothing exist like this. You may need to work with many custom images to make this happen.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        The components in the pictures are available, but I have no idea how to use them.

        L 1 Reply Last reply
        0
        • ? A Former User

          The components in the pictures are available, but I have no idea how to use them.

          L Offline
          L Offline
          lemons
          wrote on last edited by
          #4

          @NullByte definitely not the best implementation, but maybe it brings you on the right track:

          import QtQuick 2.12
          import QtQuick.Window 2.12
          import QtQuick.Controls 2.12
          import QtQuick.Layouts 1.12
          import QtGraphicalEffects 1.15
          
          Window {
              width: 320
              height: 520
              visible: true
              title: qsTr("Navbar Quick Sketch")
              ColumnLayout {
                  anchors.fill: parent
                  StackLayout {
                      Layout.fillWidth: true
                      Layout.fillHeight: true
                      currentIndex: navBar.currentIndex
                      Item {
                          Text {
                              anchors.centerIn: parent
                              text: "A"
                          }
                      }
                      Item {
                          Text {
                              anchors.centerIn: parent
                              text: "B"
                          }
                      }
                      Item {
                          Text {
                              anchors.centerIn: parent
                              text: "C"
                          }
                      }
                  }
                  // BEGIN NAVBAR
                  Item {
                      id: navBar
                      Layout.fillWidth: true
                      height: 80
          
                      property int currentIndex: 0
          
                      property var navigationModel: [{
                              "iconName": "A"
                          }, {
                              "iconName": "B"
                          }, {
                              "iconName": "C"
                          }]
          
                      property int animationInterval: 150
          
                      Item {
                          id: navBarBackground
                          anchors.fill: parent
                          // overflow outside the viewport to make outer radius invisible
                          anchors.leftMargin: -styleRadius
                          anchors.rightMargin: -styleRadius
          
                          property color backgroundColor: "#EEF3FF"
                          property int styleRadius: 20
          
                          // bottom background
                          Rectangle {
                              id: bottom
                              anchors.fill: parent
                              anchors.topMargin: parent.height / 2
                              color: parent.backgroundColor
                          }
                          // background left to indicator
                          Rectangle {
                              id: left
                              anchors.left: parent.left
                              anchors.top: parent.top
                              anchors.topMargin: parent.height * 0.15
                              anchors.right: indicator.left
                              anchors.bottom: parent.bottom
                              color: parent.backgroundColor
                              radius: parent.styleRadius
                          }
                          // the indicator part - 2 circles inside each other
                          Rectangle {
                              id: indicator
                              height: parent.height * 0.8
                              width: height
                              anchors.top: parent.top
                              color: "white"
                              radius: width / 2
                              property int itemWidth: navBar.width / navBar.navigationModel.length
                              property int offset: (itemWidth - width) / 2
                              x: parent.styleRadius + offset + itemWidth * navBar.currentIndex
          
                              Rectangle {
                                  id: highlightCircle
                                  anchors.fill: parent
                                  anchors.margins: 5
                                  radius: height / 2
                                  color: "#585CE5"
                              }
                              // add a simple shadow to the highlight
                              DropShadow {
                                  anchors.fill: highlightCircle
                                  horizontalOffset: 4
                                  verticalOffset: 4
                                  radius: 4
                                  samples: 9
                                  color: "#40000000"
                                  source: highlightCircle
                                  antialiasing: true
                              }
                              // very simple animation
                              Behavior on x {
                                  PropertyAnimation {
                                      duration: navBar.animationInterval
                                      easing.type: Easing.InOutBounce
                                  }
                              }
                          }
          
                          // background right to the indicator
                          Rectangle {
                              id: right
                              anchors.right: parent.right
                              anchors.top: parent.top
                              anchors.topMargin: parent.height * 0.15
                              anchors.left: indicator.right
                              anchors.bottom: parent.bottom
                              color: parent.backgroundColor
                              radius: parent.styleRadius
                          }
                      }
                      RowLayout {
                          anchors.fill: parent
                          anchors.topMargin: parent.height * 0.15
                          Repeater {
                              model: navBar.navigationModel
                              delegate: Item {
                                  id: delegateWrapper
                                  Layout.fillWidth: true
                                  Layout.fillHeight: true
          
                                  Text {
                                      property bool isActive: index === navBar.currentIndex
                                      parent: isActive ? indicator : delegateWrapper
                                      anchors.centerIn: parent
                                      horizontalAlignment: Text.AlignHCenter
                                      font.pointSize: 16
                                      text: modelData.iconName
                                      color: isActive ? "white" : "#9297B2"
                                  }
          
                                  MouseArea {
                                      anchors.fill: parent
                                      onClicked: {
                                          navBar.currentIndex = index
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
          }
          
          
          ? 1 Reply Last reply
          2
          • GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote on last edited by
            #5

            I shared an experiment around this in a previous forum post :
            https://forum.qt.io/topic/111454/qml-more-advanced-shapes/4

            1 Reply Last reply
            3
            • L lemons

              @NullByte definitely not the best implementation, but maybe it brings you on the right track:

              import QtQuick 2.12
              import QtQuick.Window 2.12
              import QtQuick.Controls 2.12
              import QtQuick.Layouts 1.12
              import QtGraphicalEffects 1.15
              
              Window {
                  width: 320
                  height: 520
                  visible: true
                  title: qsTr("Navbar Quick Sketch")
                  ColumnLayout {
                      anchors.fill: parent
                      StackLayout {
                          Layout.fillWidth: true
                          Layout.fillHeight: true
                          currentIndex: navBar.currentIndex
                          Item {
                              Text {
                                  anchors.centerIn: parent
                                  text: "A"
                              }
                          }
                          Item {
                              Text {
                                  anchors.centerIn: parent
                                  text: "B"
                              }
                          }
                          Item {
                              Text {
                                  anchors.centerIn: parent
                                  text: "C"
                              }
                          }
                      }
                      // BEGIN NAVBAR
                      Item {
                          id: navBar
                          Layout.fillWidth: true
                          height: 80
              
                          property int currentIndex: 0
              
                          property var navigationModel: [{
                                  "iconName": "A"
                              }, {
                                  "iconName": "B"
                              }, {
                                  "iconName": "C"
                              }]
              
                          property int animationInterval: 150
              
                          Item {
                              id: navBarBackground
                              anchors.fill: parent
                              // overflow outside the viewport to make outer radius invisible
                              anchors.leftMargin: -styleRadius
                              anchors.rightMargin: -styleRadius
              
                              property color backgroundColor: "#EEF3FF"
                              property int styleRadius: 20
              
                              // bottom background
                              Rectangle {
                                  id: bottom
                                  anchors.fill: parent
                                  anchors.topMargin: parent.height / 2
                                  color: parent.backgroundColor
                              }
                              // background left to indicator
                              Rectangle {
                                  id: left
                                  anchors.left: parent.left
                                  anchors.top: parent.top
                                  anchors.topMargin: parent.height * 0.15
                                  anchors.right: indicator.left
                                  anchors.bottom: parent.bottom
                                  color: parent.backgroundColor
                                  radius: parent.styleRadius
                              }
                              // the indicator part - 2 circles inside each other
                              Rectangle {
                                  id: indicator
                                  height: parent.height * 0.8
                                  width: height
                                  anchors.top: parent.top
                                  color: "white"
                                  radius: width / 2
                                  property int itemWidth: navBar.width / navBar.navigationModel.length
                                  property int offset: (itemWidth - width) / 2
                                  x: parent.styleRadius + offset + itemWidth * navBar.currentIndex
              
                                  Rectangle {
                                      id: highlightCircle
                                      anchors.fill: parent
                                      anchors.margins: 5
                                      radius: height / 2
                                      color: "#585CE5"
                                  }
                                  // add a simple shadow to the highlight
                                  DropShadow {
                                      anchors.fill: highlightCircle
                                      horizontalOffset: 4
                                      verticalOffset: 4
                                      radius: 4
                                      samples: 9
                                      color: "#40000000"
                                      source: highlightCircle
                                      antialiasing: true
                                  }
                                  // very simple animation
                                  Behavior on x {
                                      PropertyAnimation {
                                          duration: navBar.animationInterval
                                          easing.type: Easing.InOutBounce
                                      }
                                  }
                              }
              
                              // background right to the indicator
                              Rectangle {
                                  id: right
                                  anchors.right: parent.right
                                  anchors.top: parent.top
                                  anchors.topMargin: parent.height * 0.15
                                  anchors.left: indicator.right
                                  anchors.bottom: parent.bottom
                                  color: parent.backgroundColor
                                  radius: parent.styleRadius
                              }
                          }
                          RowLayout {
                              anchors.fill: parent
                              anchors.topMargin: parent.height * 0.15
                              Repeater {
                                  model: navBar.navigationModel
                                  delegate: Item {
                                      id: delegateWrapper
                                      Layout.fillWidth: true
                                      Layout.fillHeight: true
              
                                      Text {
                                          property bool isActive: index === navBar.currentIndex
                                          parent: isActive ? indicator : delegateWrapper
                                          anchors.centerIn: parent
                                          horizontalAlignment: Text.AlignHCenter
                                          font.pointSize: 16
                                          text: modelData.iconName
                                          color: isActive ? "white" : "#9297B2"
                                      }
              
                                      MouseArea {
                                          anchors.fill: parent
                                          onClicked: {
                                              navBar.currentIndex = index
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
              
              
              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              @lemons working like charm !

              @GrecKo thanks i will review

              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