theIndices = [1,3,5]
theQIndexObjects = [self.myQStringListModel.createIndex(rowIndex, 0, self.coverages_lm) for rowIndex in theIndices]
for Qindex in theQIndexObjects:
myListview.selectionModel().select(Qindex, QtGui.QItemSelectionModel.Select)
model = new QStringListModel(this);
listView = new QListView;
listView->setModel(model);
listView->setSelectionMode(QAbstractItemView::MultiSelection);//you can select many selections;
最后我自己想出来了,下面是答案,假设你有一个listview“myListview”,一个对应的模型“myQStringListModel”,至少有6个元素(0-5)和一个索引数组[1,3,5]:
在我看来,使用模型创建索引对象并不是很直接,但我想这是有意义的。在
我猜您使用的是QStringListModel而不是QStringModel,假设您使用的是QListView。这里是密码吗
相关问题 更多 >
编程相关推荐