Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. combo box list keeps snapping to top
Forum Updated to NodeBB v4.3 + New Features

combo box list keeps snapping to top

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 142 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.
  • K Offline
    K Offline
    kgregory
    wrote on 24 Oct 2024, 03:07 last edited by
    #1

    I have a fairly generic combo box that I use across my application. Nothing fancy, just a simple combo box that is stylized for my app's aesthetics.

    My problem is that in one instance of this combo box, there are now two many selection options to fit on the screen. When I try to scroll to the bottom of the list, it always snaps back to the first item, making it impossible to see part of the list. Can anyone tell me why it's like this or how to get it to allow me to scroll to the bottom?

    import QtQuick
    import QtQuick.Controls
    
    ComboBox{
        id: myComboBox
        property real cornerRadii: 30
        font.family: "Helvetica"
    
        delegate: ItemDelegate {
                width: myComboBox.width
                contentItem: Text {
                    text: modelData
                    color: parent.highlighted ? "#000000" : "#FFFFFF"
                    font: myComboBox.font
                    elide: Text.ElideRight
                    horizontalAlignment: Text.AlignLeft
                    verticalAlignment: Text.AlignVCenter
                }
                background: Rectangle {
                    //implicitWidth: parent.width
                    //implicitHeight: parent.height
                    //visible: myComboBox.down || myComboBox.highlighted || myComboBox.visualFocus
                    color: parent.highlighted ? "#FFFFFF" : "#00000000"
                    border.color: parent.highlighted ? "#00000000" : "#FFFFFF"
                    border.width: 1
                    radius: myComboBox.cornerRadii
                }
                highlighted: myComboBox.highlightedIndex === index
            }
        background: Rectangle {
                width: parent.width
                height: parent.height
                color: "#D0000000"
                border.color: "#FFFFFF"
                border.width: 1
                radius: myComboBox.cornerRadii
            }
        contentItem: Text {
                leftPadding: .01*parent.width
                rightPadding: parent.indicator.width + parent.spacing
    
                text: parent.displayText
                font: parent.font
                color: parent.pressed ? "#C0C0C0" : "#FFFFFF"
                horizontalAlignment: Text.AlignLeft
                verticalAlignment: Text.AlignVCenter
                elide: Text.ElideNone
            }
        popup: Popup {
                y: parent.height - 1
                width: parent.width
                implicitHeight: contentItem.implicitHeight
                padding: 1
                font: parent.font //delete this?
                
                contentItem: ListView {
                    clip: true
                    implicitHeight: contentHeight
                    model: myComboBox.popup.visible ? myComboBox.delegateModel : null
                    currentIndex: myComboBox.highlightedIndex
                    ScrollIndicator.vertical: ScrollIndicator { }
                }
    
                background: Rectangle {
                    border.color: "#FFFFFF"
                    color: "#D0000000"
                    radius: myComboBox.cornerRadii
                }
            }
    }
    
    1 Reply Last reply
    0

    1/1

    24 Oct 2024, 03:07

    • Login

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