QTreeview在键盘选中节点时如何获得信号并取得当前节点的内容
小弟第一次用QT,现在用QTreeview和QFileSystemModel结合做了个文件浏览的窗口,我需要允许用键盘选中目录,然后把选中的目录路径读出来,但是我发现QTreeView没有节点被选中的信号,类似的信号是activated(const QModelIndex &),但是这个信号需要选中节点后再按回车才能发射。谁知道怎么弄 QTreeview
[解决办法]
void QItemSelectionModel::currentChanged(const QModelIndex & current, const QModelIndex & previous) [signal]
This signal is emitted whenever the current item changes. The previous model item index is replaced by the current index as the selection's current item.
Note that this signal will not be emitted when the item model is reset.
信号糟使用QTreeView->selectionModel(),而不是QTreeView