Qt : How to get QComboBox item text at an arbitrary index (not the currently selected item)

2.4k views Asked by At

Extracting text of the selected QComboBox item is well known, but how do I get the text in a QComboBox for an arbitrary index item (not necessarily the one selected)?

1

There are 1 answers

2
Jablonski On BEST ANSWER

Use itemText() method to do this. Just set needed index.

As Marek R pointed, you can get model and get data from this model, but it will be helpful for you when you want to get something more than text( for example get image with Qt::DecorationRole or font with Qt::FontRole)

http://qt-project.org/doc/qt-4.8/qcombobox.html#itemText

http://qt-project.org/doc/qt-4.8/qcombobox.html#model