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

Cannot override popup.contentItem on ComboBox

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.7.1
    • 5.7.0
    • Quick: Controls 2
    • None
    • 50148c6fa19bb0af40a9ece8b8893ad621780745

    Description

      I cannot override popup.contentItem on ComboBox because the original ComboBox' popup references its original contentItem by id.
      So trying something like this:

          ComboBox {
              model: ["First", "Second", "Third"]
              id: combo
              popup.contentItem: Rectangle {
                  anchors.fill: parent
                  color: "blue"
                  border.color: "red"
              }
          }
      

      with the original ComboBox code:

          //! [popup]
          popup: T.Popup {
              y: control.height - (control.visualFocus ? 0 : 1)
              width: control.width
              implicitHeight: listview.contentHeight << -- fails here
              topMargin: 6
              bottomMargin: 6
      
              contentItem: ListView {
                  id: listview
                  clip: true
                  model: control.popup.visible ? control.delegateModel : null
                  currentIndex: control.highlightedIndex
      
                  Rectangle {
                      z: 10
                      parent: listview
                      width: listview.width
                      height: listview.height
                      color: "transparent"
                      border.color: "#bdbebf"
                  }
      
                  T.ScrollIndicator.vertical: ScrollIndicator { }
              }
      
              background: Rectangle { }
          }
          //! [popup]
      

      fails on the marked line with:
      ComboBox.qml:108: TypeError: Cannot read property of null

      I am not sure if users are supposed to fiddle with properties of internal child elements, so you can decide how to deal with this.

      Just as an explanation, what I was trying to do here is getting rid of the border around the popup.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            icwiener Anonymous (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes