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 357 - Custom QItemDelegate - QWidget not cast to QLineEdit
: Custom QItemDelegate - QWidget not cast to QLineEdit
Status: CLOSED DUPLICATE of bug 360
Product: PySide
Classification: Unclassified
Component: QtGui
: 0.4.1
: PC MS Windows XP/Vista/7
: P3 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2010-09-14 19:45 EEST by Chris
Modified: 2010-10-13 13:52 EEST (History)
8 users (show)

See Also:


Attachments
test case (1.27 KB, text/x-python)
2010-09-21 15:26 EEST, renato filho
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris 2010-09-14 19:45:03 EEST
Custom item delegates do not work with QTableView. I am specifically trying to
use a QLineEdit with a QRegExpValidator to validate user input. I receive the
below error:

AttributeError: 'PySide.QtGui.QWidget' object has no attribute 'setText'

Tested and failed on Ubuntu 9.10 using Python 2.6.5, PySide 0.4.0 and Windows 7
using Python 2.6.5, PySide 0.4.1 resulting in the same error.
QStyledItemDelegate also has the same problem. I have double checked and this
works as expected using PyQt4.

Code:

class CustomDelegate(QtGui.QItemDelegate):
    def __init__(self, parent=None):
        QtGui.QItemDelegate.__init__(self, parent=None)

    def createEditor(self, parent, option, index):
        editor = QtGui.QLineEdit(parent)
        regex = QtCore.QRegExp("[A-Z]{3}")
        editor.setValidator(QtGui.QRegExpValidator(regex, editor))
        return editor

    def setEditorData(self, editor, index):
        data = index.model().data(index)
        editor.setText(data)

    def setModelData(self, editor, model, index):
        if editor.hasAcceptableInput():
            model.setData(index, editor.text())

    def updateEditorGeometry(self, editor, option, index):
        editor.setGeometry(option.rect)

Best regards,
Chris
Comment 1 renato filho 2010-09-21 15:26:36 EEST
Created attachment 91 [details]
test case

I created this small test and running this with the current git mainline
version everything works fine. Can you test this?
Comment 2 renato filho 2010-09-24 17:40:25 EEST
This is the same problem found in bug #360.

fixed on shiboken commit:

commit 06f1f83e0e8f39cde919bdb8a3441823bc5a5bb2
Author: renatofilho <renato.filho@openbossa.org>
Date:   Tue Sep 21 13:41:55 2010 -0300

*** This bug has been marked as a duplicate of bug 360 ***