【问题标题】:PyQt (Python and QT) How to detect when an item in Tableview has been selected/highlighted?PyQt(Python 和 QT)如何检测 Tableview 中的项目何时被选中/突出显示?
【发布时间】:2016-04-29 03:26:36
【问题描述】:

所以伙计们,我需要一些关于 PyQt 的帮助。我对它比较陌生,还在学习。我的问题是是否有一些信号可以检测何时使用箭头选择了一个项目?例如,当光标单击某些内容时,此代码非常适合调用我的 current_selection() 方法?感谢阅读!

self.project_table_view.clicked.connect(self.current_selection)

【问题讨论】:

  • 您可以尝试连接到currentItemChanged 或itemSelectionChanged
  • 您的QTableView 有一个selection model。选择模型有一个selectionChanged 信号。
  • thuga 我看到了其他地方提到的选择模型和 selectionChanged 信号,但没有看到如何在 Python 中正确实现它们?

标签: python qt pyqt qt4 pyqt4


【解决方案1】:

感谢 thuga 和 this question,我得到了一个解决方案 这两行

selectionModel = self.view.selectionModel() selectionModel.selectionChanged.connect(self.selChanged)

【讨论】:

    猜你喜欢
    • 2016-11-24
    • 1970-01-01
    • 2012-01-23
    • 2012-02-22
    • 1970-01-01
    • 1970-01-01
    • 2021-08-22
    • 2013-04-04
    • 1970-01-01
    相关资源
    最近更新 更多