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

ui.combobox->clear();
ui.combobox->addItem(tr("全部"), -1);

幕布斯7119047
浏览 137回答 2
2回答

有只小跳蛙

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.所以后面都不是索引,使用户自定义的数据,具体意义看用户定义。

眼眸繁星

我查了Qt的Assistant,additem没有带索引的重载啊。insertitem到是有索引,不过也没有你这种调用法,你可以仔细查看Assistant,负索引是在组合框的前面添加项
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

数据结构