Change propery value inside custom style



  • Hi

    I am trying to reuse a custom ComboBoxStyle by changing the text displayed when the combo box is empty. In a separate file, CustomComboStyle.qml I have the following definition:
    @
    Component {
    ComboBoxStyle {
    label: Item {
    anchors.fill: parent
    Text {
    text: (-1 == control.currentIndex)?qsTr("Choose a task..."):control.textAt(control.currentIndex)
    }
    }
    }
    }
    @

    I need when instantiating this style to change also the text shown when currentIndex is -1. Currently I have no solution for this as properties declared inside Component are not supported, so I need to have different files just with the above text changed. Is there a more elegant solution ?

    [edit: Added coding tags @ SGaist]



  • I have found that a possible solution is to define a custom ComboBox in a separate file with the ComboBoxStyle defined inside, then properties can be defined in the ComboBox for controlling style behavior.


Log in to reply
 

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