如何在QListView中获取所选项目委托

时间:2011-08-10 07:01:13

标签: qt delegates qlistview

我想在我的QListView上实现拖放,所以我想获得所选的项目委托。我怎么能这样做?

2 个答案:

答案 0 :(得分:2)

我没有为自己测试过这个,但这是我通过阅读documentation找到的。

QListViewQList<QModelIndex>,其中包含所选项目。您可以使用QListView::selectedIndexes()

访问此列表

然后,您可以为所选索引调用QAbstractItemView::itemDelegate( const QModelIndex& index )。此函数返回QAbstractItemDelegate*

答案 1 :(得分:0)

我不确定这对你有帮助,但你可以使用这个功能:

void QListView::currentChanged ( const QModelIndex & current, const QModelIndex & previous ) [virtual protected]

void QAbstractItemView::dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ) [virtual protected slot]

并参考Qt QAbstractItemView class documentation

问候 罗伯特

相关问题