提取所选 QComboBox 项的文本是众所周知的,但我如何在 QComboBox 中获取任意索引项(不一定是所选项)的文本?
最佳答案
使用 itemText()
方法来做到这一点。只需设置所需的索引即可。
作为Marek R
指出,你可以得到模型并从这个模型中得到数据,但是当你想要得到比文本更多的东西时它会对你有所帮助(例如用 Qt::DecorationRole
得到图像或用 Qt::FontRole
得到字体)
关于c++ - Qt : How to get QComboBox item text at an arbitrary index (not the currently selected item),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26987281/