我使用的是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):有什么想法吗?或者我能读到更多关于它的文件?
发布于 2014-07-04 08:15:27
检查您的PySide版本,因为PySide不再支持QVariant。发现:这里。
请注意Python3或使用sip.setapi('QVariant', 2)和PyQt4,您将使用return QVariant()获得此错误。
TypeError: PyQt4.QtCore.QVariant represents a mapped type and cannot be instantiated我建议不要以这种方式使用QVariant。
https://stackoverflow.com/questions/24566940
复制相似问题