PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 375 - Just an empty table when using delegate.
: Just an empty table when using delegate.
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: PySide
: 0.4.1
: All Linux
: P3 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2010-09-22 05:19 EEST by Bajusz Tamás
Modified: 2010-10-13 13:48 EEST (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bajusz Tamás 2010-09-22 05:19:46 EEST
# I got an empty table when using setItemDelegate(). Without delegate it's Ok.
# With PyQt4 it's Ok with or without using the delegate.

USE_PYSIDE = False
USE_PYSIDE = True

if USE_PYSIDE:
    from PySide import QtCore
    from PySide import QtGui
    from PySide.QtCore import QProperty as pyqtProperty
    qcolor = QtGui.QColor
else:
    import sip
    sip.setapi('QString', 2)
    sip.setapi('QVariant', 2)
    from PyQt4 import QtCore
    from PyQt4 import QtGui
    from PyQt4.QtCore import pyqtProperty
    qcolor = QtCore.QVariant.Color


class MyDelegate(QtGui.QStyledItemDelegate):
    pass

class MyModel(QtCore.QAbstractTableModel):
    def __init__(self):
        QtCore.QAbstractTableModel.__init__(self)

        self.rows = [['one', 1], ['two', 2], ['three', 3]]
        self.header = ('str', 'int')

    def columnCount(self, parent=None):
        return 2

    def rowCount(self, parent=None):
        return 3

    def index(self, row, column, parent=None):
        return self.createIndex(row, column, 0)

    def parent(self, index):
        return QtCore.QModelIndex()

    def data(self, index, role):
        return self.rows[index.row()][index.column()]

    def setData(self, index, value, role):
        return True

    def headerData(self, section, orientation, role):
        return self.header[section-1]

    def flags(self, index):
        return QtCore.QAbstractTableModel.flags(self, index)


class Window(QtGui.QTableView):
    def __init__(self):
        QtGui.QTableView.__init__(self)

        self.setModel(MyModel())
        self.setItemDelegate(MyDelegate())

if __name__ == '__main__':
    import sys
    app = QtGui.QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec_())
Comment 1 Hugo Parente Lima 2010-09-27 16:36:01 EEST
Fixed in commit:

pyside/199b8b3baee2e3297413636a63ca09abe6aac39a
Comment 2 renato filho 2010-10-13 13:48:55 EEST
released on PySide 0.4.2