problem in customise combobox in qml

  • Hi
    i was create a customise the combobox with textfield and listview. In that i can update the different c++model date to the listview. Herewith i post some code sample. i don't know how to pass textRole from one file to another file.


    id: cb
    property alias dropDownModel: dropDownView.model
    property var textRole
    TextField {
    id: tf
    height: 50
    width: 200
    anchors.fill: parent
    onClicked :{
    dropDownList.visible = true
    Rectangle {
    id: dropDownList
    width: 100
    height: 500
    clip: true
    visible: false tf.bottom
    anchors.left: tf.left
    anchors.topMargin: 10
    ScrollView {
    anchors.fill: dropDownList
    ListView {
    id: dropDownView
    anchors.fill: parent
    anchors.leftMargin: 2
    anchors.rightMargin: 5
    delegate: dropDownDelegate
    focus: true
    interactive: true
    highlight: Rectangle {
    color: "#96A3CB"
    width: dropDownList.width
    radius: 5
    highlightFollowsCurrentItem: true
    highlightMoveDuration: 10
    //delegate component:
    Component {
    id: dropDownDelegate

        Rectangle {
            id: dropDownItem
            width: cb.width
            height: cb.height
            color: "transparent"
            Column {
                anchors {
                    verticalCenter: parent.verticalCenter
                    left: parent.left
                    leftMargin: 5
                Text {
                    text: mydelegate
                    font.pixelSize: 18
            MouseArea {
                anchors.fill: dropDownItem
                onClicked: {
                    dropDownView.currentIndex = index
                    cb.currentText = textRole
                    tf.text = textRole


    MyCombo {
    id: cbx
    width: 203
    height: 35
    dropDownModel: model2
    Note: I update the c++ QAbstractmodel to qml.

    I dont know, how to pass the textrole value from main.qml to MyCombo.qml. I tried to pass the value using string and var type, it shows error.
    Let me know any possible solution for this problem.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.