Created
August 24, 2017 19:14
-
-
Save khmaksim/5a88785c01ea59ca9d70afff41b48a39 to your computer and use it in GitHub Desktop.
QML ComboBox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.0 | |
import QtQuick.Controls 1.4 | |
import QtQuick.Controls.Styles 1.4 | |
import QtQuick.Controls.Private 1.0 | |
ComboBox | |
{ | |
id: box | |
currentIndex: 2 | |
activeFocusOnPress: true | |
style: ComboBoxStyle { | |
id: comboBox | |
background: Rectangle { | |
id: rectCategory | |
color: "transparent" | |
border.width: 1 | |
border.color: "white" | |
radius: 15 | |
} | |
label: Text { | |
verticalAlignment: Text.AlignVCenter | |
horizontalAlignment: Text.AlignHCenter | |
font.pointSize: 15 | |
font.family: "Courier" | |
font.capitalization: Font.SmallCaps | |
color: "white" | |
text: control.currentText | |
} | |
// drop-down customization here | |
property Component __dropDownStyle: MenuStyle { | |
__maxPopupHeight: 600 | |
__menuItemType: "comboboxitem" | |
frame: Rectangle { // background | |
color: "green" | |
border.width: 1 | |
border.color: "white" | |
radius: 15 | |
} | |
padding.top: 12 | |
padding.bottom: 12 | |
itemDelegate.label: // an item text | |
Text | |
{ | |
verticalAlignment: Text.AlignVCenter | |
horizontalAlignment: Text.AlignHCenter | |
font.pointSize: 15 | |
font.family: "Courier" | |
font.capitalization: Font.SmallCaps | |
color: "white" | |
text: styleData.text | |
} | |
itemDelegate.background: Rectangle { // selection of an item | |
radius: 5 | |
color: styleData.selected ? "#1fcecb" : "transparent" | |
} | |
__scrollerStyle: ScrollViewStyle { } | |
} | |
property Component __popupStyle: Style { | |
property int __maxPopupHeight: 400 | |
property int submenuOverlap: 100 | |
property Component menuItemPanel: Text { | |
text: "NOT IMPLEMENTED" | |
color: "red" | |
font { | |
pixelSize: 14 | |
bold: true | |
} | |
} | |
property Component __scrollerStyle: null | |
} | |
} | |
model: ListModel { | |
id: cbItems | |
ListElement { text: "Banana" } | |
ListElement { text: "Apple" } | |
ListElement { text: "Coconut" } | |
} | |
width: 200 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment