pyqt4 - 如何在 PyQt4 中为 QListView 获取 selectionchange 事件

标签 pyqt4 qlistview

嗨,有一个使用 QtDesigner 创建并使用 pyuic4 转换为 python 的 QListView,我导入了 UI 模块,我试图将它连接到事件

对于 QlistView 我正在尝试在用户按下向上和向下键时实现选择更改,我猜应该在选择更改时触发该事件,但这似乎没有做任何事情

self.methodListView.selectionModel.selectionChanged.connect(self.outputHelp)

但这给出了错误
AttributeError: 'builtin_function_or_method' object has no attribute 'selectionChanged'

我是否需要添加更多信息来准确显示我在做什么?

最佳答案

self.methodListView.selectionModel不是属性,它是返回选择模型的函数。只需使用

self.methodListView.selectionModel().selectionChanged.connect(self.outputHelp)

它应该工作......

关于pyqt4 - 如何在 PyQt4 中为 QListView 获取 selectionchange 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19605302/

相关文章:

python - PyQt5 可将图标从 ListView 拖动到另一个 ListView

qt - 如何在 QListView 中选择一行

python - Qt : Updating UI (with signals) from another class and thread

qt - 如何知道 QML QListView 中的所选项目何时发生更改?

c++ - 多列列表的 Qt 最佳控件?

python - QAbstractTableModel 作为一个 QTableView 和几个 QListView 的模型

c++ - QT4 qlistview保存手动移动的图标位置,下次使用

python - 在 PyQt4 中使用 KWallet

Qt 或 PyQt4 - 如何拉出并嵌入 YouTube 剪辑框?

python - %matplotlib qt 不工作