为了账号安全,请及时绑定邮箱和手机立即绑定

为什么会有-1,索引最小就是0啊?

为什么会有-1,索引最小就是0啊?

幕布斯7119047 2022-12-15 18:14:01
ui.combobox->clear();ui.combobox->addItem(tr("全部"), -1);
查看完整描述

2 回答

?
有只小跳蛙

TA贡献1824条经验 获得超8个赞

void QComboBox::addItem ( const QString & text, const QVariant & userData= QVariant() )
Adds an item to the combobox with the given text, and containing the specified userData (stored in the Qt::UserRole). The item is appended to the list of existing items.
所以后面都不是索引,使用户自定义的数据,具体意义看用户定义。

查看完整回答
反对 回复 2022-12-18
?
眼眸繁星

TA贡献1873条经验 获得超9个赞

我查了Qt的Assistant,additem没有带索引的重载啊。insertitem到是有索引,不过也没有你这种调用法,你可以仔细查看Assistant,负索引是在组合框的前面添加项

查看完整回答
反对 回复 2022-12-18
  • 2 回答
  • 0 关注
  • 136 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号