Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 QFileSystemModel 中,当对其进行选择时,返回类型为QList<QModelIndex>. 有没有办法只选择第一列(包含驱动器、文件夹和文件的列)?
QList<QModelIndex>
如果您对特定选择感兴趣,您应该对列表中的每个 QModelIndex 执行以下操作:
QFileSystemModel* p_fs_model; ... foreach(QModelIndex index, whole_selection) { QModelIndex first_column_index = p_fs_model->index( index->row(), 0, /* first column index */ index->parent() ); ... }