Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)?

like image 788
daj Avatar asked Oct 24 '25 04:10

daj


1 Answers

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

like image 179
Kosovan Avatar answered Oct 25 '25 17:10

Kosovan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!