Combobox select line by letter



  • Hey!

    I have a combobox where I want to be able to just press any key on the keyboard and jump to the first line which starts with this letter. The problem is, it is working when the combobox is closed but still have the focus. But when you open the combobox and the drop down menu comes down, it doesnt work anymore? Guess the focus needs to be on the drop down menu? Is that correct? cant get it to work!

    Any help?

    @
    //Drop down menu for the language list
    ComboBox{
    id: comboBox;
    width: caText.width;
    model: languageList.langList;
    textRole: "langDescription";
    style: ComboBoxStyle{
    __dropDownStyle: MenuStyle{
    itemDelegate.label: Text {
    text: formatMnemonic(styleData.text, styleData.underlineMnemonic)
    color: __currentTextColor
    font.pixelSize: __labelFontPixelSize
    renderType: Text.NativeRendering
    }
    }
    }
    onPressedChanged: {
    focus = true;
    }

                    Keys.onPressed: {
                        console.log(currentIndex = languageList.sortByLetter(event.text, currentIndex));
                    }
    
                    }
    

    @



  • I would think you should do it yourself and catch the keypress event and find the first one in the list and set that index as focus.



  • I do do it myself. I get the correct index, but that is only when the combobox is closed. When it is open it doesnt work.


Log in to reply
 

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