QTreeview在键盘选中节点时如何获得信号并取得当前节点的内容

killer1978 2013-09-15 03:45:07
小弟第一次用QT,现在用QTreeview和QFileSystemModel结合做了个文件浏览的窗口,我需要允许用键盘选中目录,然后把选中的目录路径读出来,但是我发现QTreeView没有节点被选中的信号,类似的信号是activated(const QModelIndex &),但是这个信号需要选中节点后再按回车才能发射。谁知道怎么弄
...全文
1048 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
loveabcc 2015-01-09
  • 打赏
  • 举报
回复
楼主你好 我也遇到同样的问题, 具体怎么做的啊 怎么触发 这个 信号呢
killer1978 2013-09-15
  • 打赏
  • 举报
回复
正解,给分
引用 1 楼 Inhibitory 的回复:
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
引用 1 楼 Inhibitory 的回复:
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
killer1978 2013-09-15
  • 打赏
  • 举报
回复
楼上正解,这个问题困扰我2天了,查QT的资料没能直接看出来,郁闷啊
Inhibitory 2013-09-15
  • 打赏
  • 举报
回复
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

16,211

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧