[PyQt] returning numpy numbers in QVariant
Jeremy Sanders
jeremy at jeremysanders.net
Tue Apr 20 22:35:03 BST 2010
Hi - some of my code has stopped working after upgrading to PyQt 4.7. It
seems numbers in numpy arrays used to convert okay to QVariant types, but
now they seem to produce blank results:
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import numpy
class Model(QAbstractTableModel):
def columnCount(self, parent):
return 1
def rowCount(self, parent):
return 100
def data(self, index, role):
if role == Qt.DisplayRole:
a = numpy.array([index.row()*0.1])
return QVariant(a[0])
else:
return QVariant()
if __name__ == "__main__":
app = QApplication(sys.argv)
win = QTableView()
mod = Model()
win.setModel(mod)
win.show()
app.exec_()
This should show a list of numbers in the QTableView. It did and does not
any longer.
Is this a bug or shouldn't I be doing this?
Thanks again
Jeremy
--
http://www.jeremysanders.net/
More information about the PyQt
mailing list