Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No QVariant attributes

Tags:

python

pyqt

I am using from qtswitch import QtGui, QtCore instead of the usual from PyQt4 import QtGui, QtCore, and there are some parts in which I am having trouble.

One of them is the error where in one of my function, I had it return QtCore.QVariant() and I keep getting the following error

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

and the opening sentence of the function is as follows:

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

Any ideas? Or perhaps are there more documentations that I can read up on it?

like image 580
dissidia Avatar asked Oct 16 '25 04:10

dissidia


1 Answers

Check your PySide version as PySide no longer supports QVariant. As found: here.

Please note on Python 3 or using sip.setapi('QVariant', 2) with PyQt4 you would get this error using return QVariant():

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

I would suggest moving away from using QVariant in this way.

like image 179
Shadow9043 Avatar answered Oct 17 '25 17:10

Shadow9043



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!