使用 PyQt 连接 QTableView selectionChanged 信号会产生段错误 [英] Connecting QTableView selectionChanged signal produces segfault with PyQt

查看:37
本文介绍了使用 PyQt 连接 QTableView selectionChanged 信号会产生段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 PyQt 应用程序中有一个 QTableView,我想跟踪选择更改的时间.我尝试将信号连接到一个插槽,如下所示(使用 this page 上的建议:

I have a QTableView in a PyQt application, and I want to keep track of when the selection changes. I've tried connecting the signal to a slot as follows (using the advice on this page:

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

它所连接的插槽定义为:

where the slot it is connected to is defined as:

def selChanged(self, selected, deselected):
        print "Sel changed"

但是,每当我加载 QTableView 所在的 QMainWindow 时,我都会立即收到分段错误.

However, whenever I load the QMainWindow on which the QTableView resides, I get an immediate segmentation fault.

我是不是在做傻事?

推荐答案

现在已经解决了,原来我在那台机器上使用的是旧版本的 Qt - 这似乎导致了崩溃.

This has been fixed now, it turned out that I was using an old version of Qt on that machine - which seemed to cause the crash.

这个故事的寓意是:如果您的代码无缘无故崩溃,请检查您的所有依赖项(在本例中为 Qt 和 PyQt)是否是最新的.

The moral of the story is: if your code is crashing for no sensible reason, check all of your dependencies (in this case Qt and PyQt) are up-to-date.

这篇关于使用 PyQt 连接 QTableView selectionChanged 信号会产生段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆