Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-93856

Menus with a certain fixed height, element height and window height not scrolled when they should

    XMLWordPrintable

Details

    • Linux/X11
    • d0a83e333 (dev), e6478662c (6.6), 933ef0333 (tqtc/lts-6.5), 94d61bc08 (tqtc/lts-6.2)

    Description

      I have this code:

       

       

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Window 2.15
      
      Window {
          id: root
          
          width: 1024
          height: 768 // if this height is decreased, say to 480, the bug doesn't reproduce
          visible: true
          title: qsTr("Hello World")
          
          MenuBar {
              height: 30
              width: 120
      
              background: Rectangle {
                  color: '#060607'
                  radius: 15
              }
      
              anchors {
                  right: parent.right
                  bottom: parent.bottom
              }
      
              Menu {
                  id: control
                  
                  width: 245
                  height: 378 // important - I set a fixed height to the menu
      
                  title: new Date().toLocaleString(Qt.locale(), "MMM dd, hh:mm t")
      
                  delegate: MenuItem {
                      id: menuItem
                      
                      height: 20 // decrease the default height; if it's 40 or more, the bug doesn't reproduce
                  }
                  
                  Action {
                      text: qsTr("UTC - Coordinated Universal Time ")
                      onTriggered: userSettings.setTimeZone("UTC")
                  }
                  Action {
                      text: qsTr("HST - Hawaii Standard Time ")
                      onTriggered: userSettings.setTimeZone("Pacific/Honolulu")
                  }
                  Action {
                      text: qsTr("AKT - Alaska Time")
                      onTriggered: userSettings.setTimeZone("America/Juneau")
                  }
                  Action {
                      text: qsTr("PT - Pacific Time")
                      onTriggered: userSettings.setTimeZone("America/Los_Angeles")
                  }
                  Action {
                      text: qsTr("MT - Mountain Time")
                      onTriggered: userSettings.setTimeZone("America/Boise")
                  }
                  Action {
                      text: qsTr("CT - Central Time")
                      onTriggered: userSettings.setTimeZone("America/Chicago")
                  }
                  Action {
                      text: qsTr("ET - Eastern Time")
                      onTriggered: userSettings.setTimeZone("America/Detroit")
                  }
                  Action {
                      text: qsTr("AT - Atlantic Time")
                      onTriggered: userSettings.setTimeZone("America/Glace_Bay")
                  }
                  Action {
                      text: qsTr("NT - Newfoundland Time")
                      onTriggered: userSettings.setTimeZone("America/St_Johns")
                  }
                  Action {
                      text: qsTr("ART - Argentina Time")
                      onTriggered: userSettings.setTimeZone("America/Argentina/Buenos_Aires")
                  }
                  Action {
                      text: qsTr("BRT - Brasilia Time")
                      onTriggered: userSettings.setTimeZone("America/Argentina/Catamarca")
                  }
                  Action {
                      text: qsTr("WET - Western Unropean Time")
                      onTriggered: userSettings.setTimeZone("Europe/Lisbon")
                  }
                  Action {
                      text: qsTr("CET - Central European Time")
                      onTriggered: userSettings.setTimeZone("Europe/Ljubljana")
                  }
                  Action {
                      text: qsTr("EET – Eastern European Time")
                      onTriggered: userSettings.setTimeZone("Europe/Kiev")
                  }
                  Action {
                      text: qsTr("MSK – Moscow Standard Time")
                      onTriggered: userSettings.setTimeZone("Europe/Moscow")
                  }
                  Action {
                      text: qsTr("IST – India Standard Time")
                      onTriggered: userSettings.setTimeZone("Asia/Kolkata")
                  }
                  Action {
                      text: qsTr("CCT - China Coast Time")
                      onTriggered: userSettings.setTimeZone("Asia/Shanghai")
                  }
                  Action {
                      text: qsTr("JST – Japan Standard")
                      onTriggered: userSettings.setTimeZone("Asia/Tokyo")
                  }
                  Action {
                      text: qsTr("AWST – Australian Western")
                      onTriggered: userSettings.setTimeZone("Australia/Perth")
                  }
                  Action {
                      text: qsTr("ACST – Australian Central Standard Time")
                      onTriggered: userSettings.setTimeZone("Australia/Adelaide")
                  }
                  Action {
                      text: qsTr("AEST – Australian Eastern Standard Time")
                      onTriggered: userSettings.setTimeZone("Australia/Brisbane")
                  }
                  Action {
                      text: qsTr("NZT - New Zealand Time")
                      onTriggered: userSettings.setTimeZone("Pacific/Auckland")
                  }
                  Action {
                      text: qsTr("Locale Time")
                      onTriggered: userSettings.setTimeZone("local_time")
                  }
              }
          }
      }
      

       

       

      if you start it, you'll notice that not all items are visible but it doesn't scroll. The reason is this piece in Menu.qml:

      contentItem: ListView {
          implicitHeight: contentHeight
          model: control.contentModel
          interactive: Window.window
                          ? contentHeight + control.topPadding + control.bottomPadding > Window.window.height
                          : false
          clip: true
          currentIndex: control.currentIndex
      
          ScrollIndicator.vertical: ScrollIndicator {}
      }

      See the value of interactive. Assuming Window.window correctly returns the main window instead of the Popup that the menu is, using its height is incorrect. Instead, the height of the menu itself should be used (control.height).

       

      Attachments

        For Gerrit Dashboard: QTBUG-93856
        # Subject Branch Project Status CR V

        Activity

          People

            mhqanbari MohammadHossein Qanbari
            ddobrev Dimitar Dobrev
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes