qt - 如何在 QListView 中获取所选项目委托(delegate)

标签 qt delegates qlistview

我想在我的 QListView 上实现拖放,所以我想获取所选项目委托(delegate)。我怎样才能做到这一点?

最佳答案

我还没有亲自测试过这一点,但这是我通过阅读 documentation 发现的.

QListView有一个QList<QModelIndex>其中包含选定的项目。您可以使用 QListView::selectedIndexes() 访问此列表.

然后您可以调用QAbstractItemView::itemDelegate( const QModelIndex& index )对于您选择的索引。该函数返回 QAbstractItemDelegate* .

关于qt - 如何在 QListView 中获取所选项目委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7006998/

相关文章:

c++ - 如何在 Qt 程序中实现 IDv3 标签?

c# - 与委托(delegate)一起解释这段代码

qt - QListWidget或QListView与QItemDelegate?

python - 如何用值填充 QListView 并显示数据?

c++ - Visual C++ 2010 速成版 : How to use with Qt?

c++ - func ("") 导致“重载 QChar(const char[2]) 的调用不明确

c# - 在 ASP.NET 中使用委托(delegate)来处理异步操作

python - 为什么执行委托(delegate)函数时 Python 回溯很糟糕

c++ - 我如何在 QT 中将 SSL 证书添加到我的代码中