QML combobox popup out of the window bounds

334 Views Asked by At

I am creating a custom ComboBox in QML and need the popup to be able to extend beyond the window borders.

desired

I'm using QtQuick.Controls.Universal to customize it. However, when I implement it, the parent Window clips the Popup. I tried using Menu instead, but that didn't work.

Here's the code I'm using:

popup: Controls.Popup {
  y: root.height
  width: root.width
  implicitHeight: contentItem.implicitHeight
  padding: 0
  closePolicy: Controls.Popup.CloseOnPressOutsideParent

  contentItem: ListView {
    id: itemsView
    z: 1
    implicitHeight: contentHeight
    boundsBehavior: Flickable.StopAtBounds
    model: root.popup.visible ? root.delegateModel : null
    currentIndex: root.highlightedIndex
  }
  
  background: Item { }
}

Here's what I'm getting:

enter image description here

How can I prevent the Popup from being clipped by the parent Window? One solution I've found is to replace Popup with Window, but that would require me to set the x and y values manually, which I'm trying to avoid. I want the Window (Popup, Menu, etc) to be positioned directly below the ComboBox.

Additional information:

  • Qt 6.5.1
  • Windows 11
0

There are 0 best solutions below