gpt4 book ai didi

python - 没有 QVariant 属性

转载 作者:太空宇宙 更新时间:2023-11-04 01:16:07 25 4
gpt4 key购买 nike

我正在使用 from qtswitch import QtGui, QtCore 而不是通常的 from PyQt4 import QtGui, QtCore,有些部分我遇到了麻烦。

其中一个是错误,在我的一个函数中,我有它 return QtCore.QVariant() 并且我不断收到以下错误

AttributeError: 'module' object has no attribute 'QVariant'

函数的开头语句如下:

def input(self, index, role=QtCore.Qt.DisplayRole):

有什么想法吗?或者是否有更多我可以阅读的文档?

最佳答案

检查您的 PySide 版本,因为 PySide 不再支持 QVariant。发现:here .

请注意,在 Python 3 上或使用 sip.setapi('QVariant', 2) 和 PyQt4 时,使用 return QVariant() 时会出现此错误:

TypeError: PyQt4.QtCore.QVariant represents a mapped type and cannot be instantiated

我建议不要以这种方式使用 QVariant。

关于python - 没有 QVariant 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24566940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com