我有QComboBox
一个QSqlQueryModel
作为它的模型。该模型由
SELECT type_id, type FROM types
where type_id
isint
且 type 为 a的数据库构建varchar
。
I set the QComboBox
visible column with the setModelColumn(1)
function, to see the actual types, instead of the indexes, but when a value is selected, I need to retrieve the type_id
and I don't know how to achieve that. 我不能在这里使用该currentIndex()
功能,因为 的当前索引QComboBox
对我来说没用。
我认为正确的功能是currentData()
,但我无法弄清楚,如何从第一列获取数据......