Reputation: 231
I started watching some tutorials for Python and QT (https://www.youtube.com/watch?v=Eq7__6y0jwo&index=3&list=PL19DCiIwVefyQxlDTWlXQ4lnZDPW6_r-q) but I'm getting this error "QPainter::begin: Paint device returned engine == 0, type: 0" and I can't figure out why. The idea is that I want to have a window that works in 3dsMax, Modo and maybe as a standalone (Both 3dsMax and Modo come with PySide).
Any ideas?
Here is the code:
from PySide import QtCore, QtGui
import sys
class PaletteListModel (QtCore.QAbstractListModel):
def __init__(self, colors=[], parent=None):
QtCore.QAbstractListModel.__init__(self, parent)
self._colors = colors
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
listView = QtGui.QListView()
listView.show()
red = QtGui.QColor(255, 0, 0)
green = QtGui.QColor(0, 255, 0)
blue = QtGui.QColor(0, 0, 255)
model = PaletteListModel([red, green, blue])
listView.setModel(model)
sys.exit(app.exec_())
Thanks,
Nick
Upvotes: 0
Views: 1011
Reputation: 2053
The only thing I see wrong with your code is you are inheriting from QAbstractListModel without implementing the abstract methods.
From the documentation here: http://doc.qt.io/qt-5/qabstractlistmodel.html#details
When subclassing QAbstractListModel, you must provide implementations of the rowCount() and data() functions. Well behaved models also provide a headerData() implementation.
Are leaving out any code? Do you ever create a QPainter object?
Upvotes: 1