Skip to content
  • 0 Votes
    5 Posts
    2k Views
    SGaistS

    Thanks for the detailed deep dive !

  • 0 Votes
    4 Posts
    10k Views
    JLimbockerJ

    I've worked it out. Here's my code for the ComboBox. It has the following behavior:

    Currently selected value is highlighted When "Enter" Pressed: ComboBox Closes/loses focus No indicator button has custom background

    Code is below:

    ComboBox { id: groupSelect y: 3 width: 85 height: 33 model: groupList anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: 6 anchors.left: btnGroup.right anchors.leftMargin: 6 Keys.onPressed: { if(event.key == Qt.Key_Enter || event.key == Qt.Key_Return) { groupSelect.focus = false } } contentItem: Text { color : "#ffffff" text: parent.displayText font.family: "Arial"; font.pixelSize: 16; verticalAlignment: Text.AlignVCenter; horizontalAlignment: Text.AlignLeft; } background: Rectangle{ gradient: Gradient { GradientStop { position: 0.0; color: "#69697C" } GradientStop { position: 1.0; color: "#424251" } } } indicator: Rectangle { } delegate: ItemDelegate { width: groupSelect.width contentItem: Text { text:modelData; horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.family: "Arial"; font.pixelSize: 16; color: "#ffffff" } onClicked: { groupSelect.currentIndex = index listview.currentIndex = index } } popup: Popup { id: groupPopup width: parent.width height: parent.height*parent.count implicitHeight: listview.contentHeight margins: 0 background: Rectangle { color: "#424251" } contentItem: ListView { id: listview anchors.fill: parent model: groupSelect.model boundsBehavior: Flickable.StopAtBounds highlight: Rectangle { color: "#69697C" } spacing: 0 highlightFollowsCurrentItem: true currentIndex: groupSelect.highlightedIndex delegate: groupSelect.delegate } } textRole: "key" ListModel { id: groupList ListElement { key: "Group 1"; } ListElement { key: "Group 2"; } ListElement { key: "Group 3"; } } }
  • 0 Votes
    3 Posts
    4k Views
    _
    ...
    OK, this works. I thought that control was a reserved keyword.

    <u>For readers :</u>
    Since I have many TabButton, I don't use id: control as suggested but parent.

    TabButton { id: tabButtonMenu width: 100 height: parent.height text: "Menu" contentItem: Text { text: parent.text font: parent.font opacity: enabled ? 1.0 : 0.3 color: parent.down ? "yellow" : "white" horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } }
  • 0 Votes
    4 Posts
    1k Views
    mrjjM

    @JulienD
    Np. You can style the whole application however. All controls etc
    can be controlled with style sheet.
    Just not Caption :)

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    22 Posts
    13k Views
    p3c0P

    @beidaochuan That's good :)
    If you are done, please mark the post as solved.