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. Custom ComboBox : ListView doesn't display text when ElideRight
QtWS25 Last Chance

Custom ComboBox : ListView doesn't display text when ElideRight

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlqt quickquick controlscombobox style
1 Posts 1 Posters 161 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.
  • L Offline
    L Offline
    lucast
    wrote on last edited by
    #1

    Hello, I'm writing a customization of QtQuick Controls ComboBox for my style, and I 've got an issue that I doesn't understand.

    Here is a first simplified code of a customization that works

    (It's a pastebin link, else askimet consider it's a spam)
    MyStyle/ComboBox.qml

    This result in this ComboBox
    bdf702d0-7424-400e-bf22-e609daf881e0-image.png

    So I would like to ElideRight the text in the Popup's ListView's delegate

    delegate: ItemDelegate {
            id: delegate
            required property var model
            required property int index
    
            width: control.width
            height: Math.max(control.implicitHeight, implicitContentHeight)
    
            highlighted: control.highlightedIndex === index
            hoverEnabled: control.hoverEnabled
    
            contentItem: Text {
                text: delegate.model[control.textRole]
                anchors.verticalCenter: parent.verticalCenter
                width: delegate.width
                color: control.textAndBorderColor
                font: control.currentIndex === index ? Theme.fonts.title : Theme.fonts.textBig
                elide: Text.ElideRight                                   //I just add this line
                horizontalAlignment: Text.AlignLeft
                verticalAlignment: Text.AlignVCenter
            }
    
            background: Rectangle{color: "transparent"}
        }
    

    And this make the ListView unable to display the text

    19051f7c-ddc7-45d4-9a52-12c2a97b2ee8-image.png

    The strange thing is that it's like if the text is behind another element, because when I select a line, the previous and new text lines quick appears during the time the popup exit (here is with a 5s exit animation)

    combobox not display text short‐ Réalisée avec Clipchamp.gif

    I don't understand why the elide mode change this. the Text width is specified, and if I set another elide mode (ElideNone/ElideLeft/ElideMiddle), it works.
    I've tested this aside in another Popup on my app (not related to T.ComboBox) and it worked well, it seems that the issue is specific to the ComboBox's popup property

    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