Re: [PyKDE] Bug in PyQt4 QListWidget?

2006-08-06 Thread Andreas Pakulat
On 06.08.06 10:56:26, Serge Weinstock wrote:
> I'm trying to fill a Qt4 list widget using an ItemModel.

Then you're doing the wrong thing. Either use a ListView+Model or use
the QListWidgetItem's to populate the list. AFAIK this is clearly
documented in the Model/View section.

Andreas

-- 
Best of all is never to have been born.  Second best is to die soon.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Pb with QTextDocument.clone()

2006-08-06 Thread Xavier Décoret
Hello, the following simple code crashes python under windows. Under 
linux, it randomly crashes but less often. It really sounds like a 
deallocated object problem. I am using Qt4.1.4 with PyQt4.0.1 and Python 
2.4.

Am I missing something or should I do a bug report?

from PyQt4.QtCore import *
from PyQt4.QtGui import *

import sys

app = QApplication(sys.argv)

doc = QTextDocument()
doc.setHtml("hello")

clo = doc.clone()



___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Bug in PyQt4 QListWidget?

2006-08-06 Thread Serge Weinstock
Hi,

I'm trying to fill a Qt4 list widget using an ItemModel.
The items are correctly displayed but when I try to click on one of the
item, the application crashes.

I've wrote a simple test:  
==
import sys
from PyQt4 import QtCore, QtGui

class MyListModel(QtCore.QAbstractListModel):
def __init__(self):
QtCore.QAbstractListModel.__init__(self)
self.items = [ "item %d" % i for i in xrange(50)]
def rowCount(self, parent):
if parent.isValid():
return 0
return len(self.items)
def data(self, index, role):
if (index.isValid() and
index.row() < len(self.items) and
role == QtCore.Qt.DisplayRole):
return QtCore.QVariant(self.items[index.row()])
return QtCore.QVariant()

class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
   
Dialog.resize(QtCore.QSize(QtCore.QRect(0,0,274,180).size()).expandedTo(Dialog.minimumSizeHint()))

self.vboxlayout = QtGui.QVBoxLayout(Dialog)
self.vboxlayout.setMargin(9)
self.vboxlayout.setSpacing(6)
self.vboxlayout.setObjectName("vboxlayout")

self.listWidget = QtGui.QListWidget(Dialog)
self.listWidget.setObjectName("listWidget")
self.vboxlayout.addWidget(self.listWidget)

self.okButton = QtGui.QPushButton(Dialog)
self.okButton.setObjectName("okButton")
self.okButton.setText("Quit")
self.vboxlayout.addWidget(self.okButton)

self.model = MyListModel()
self.listWidget.setModel(self.model)
   
   
QtCore.QObject.connect(self.okButton,QtCore.SIGNAL("clicked()"),Dialog.accept)
   
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
==

When I click on an item, the application crashes and GDB gives me the
following trace:
==
#0  0xb7112c8e in QListWidget::qt_metacall () from /usr/lib/libQtGui.so.4
#1  0xb710e5f7 in QListWidget::metaObject () from /usr/lib/libQtGui.so.4
#2  0x0008 in ?? ()
#3  0x0001 in ?? ()
#4  0x0048 in ?? ()
#5  0xbf970f4c in ?? ()
#6  0x0001 in ?? ()
#7  0xb7218038 in ?? () from /usr/lib/libQtGui.so.4
#8  0xbf970a38 in ?? ()
#9  0xb71114ab in QListWidget::indexFromItem () from /usr/lib/libQtGui.so.4
#10 0xb71114ab in QListWidget::indexFromItem () from /usr/lib/libQtGui.so.4
#11 0xb7112b3d in QListWidget::qt_metacall () from /usr/lib/libQtGui.so.4
#12 0xb78fdc49 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#13 0xb78fdeea in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#14 0xb70c52e3 in QAbstractItemView::pressed () from /usr/lib/libQtGui.so.4
#15 0xb70c7aed in QAbstractItemView::mousePressEvent () from
/usr/lib/libQtGui.so.4
#16 0xb7479f9c in initQtGui () from
/usr/lib/python2.4/site-packages/PyQt4/QtGui.so
#17 0xb6dfdb22 in QWidget::event () from /usr/lib/libQtGui.so.4
#18 0xb6ffb0d4 in QFrame::event () from /usr/lib/libQtGui.so.4
#19 0xb7073ade in QAbstractScrollArea::viewportEvent () from
/usr/lib/libQtGui.so.4
#20 0xb70c95a2 in QAbstractItemView::viewportEvent () from
/usr/lib/libQtGui.so.4
#21 0xb7474bbc in initQtGui () from
/usr/lib/python2.4/site-packages/PyQt4/QtGui.so
#22 0xb7072dd1 in QAbstractScrollArea::~QAbstractScrollArea () from
/usr/lib/libQtGui.so.4
#23 0xb6dba201 in QApplicationPrivate::notify_helper () from
/usr/lib/libQtGui.so.4
#24 0xb6dbb67c in QApplication::notify () from /usr/lib/libQtGui.so.4
#25 0xb756f0e3 in initQtGui () from
/usr/lib/python2.4/site-packages/PyQt4/QtGui.so
#26 0xb6e0fda2 in QApplication::x11ProcessEvent () from
/usr/lib/libQtGui.so.4
#27 0xb6e0f453 in QApplication::x11ProcessEvent () from
/usr/lib/libQtGui.so.4
#28 0xb6e20c95 in non-virtual thunk to QDesktopWidget::~QDesktopWidget()
() from /usr/lib/libQtGui.so.4
#29 0xb78ee134 in QEventLoop::processEvents () from /usr/lib/libQtCore.so.4
#30 0xb78ee2fa in QEventLoop::exec () from /usr/lib/libQtCore.so.4
#31 0xb78f16d6 in QCoreApplication::exec () from /usr/lib/libQtCore.so.4
#32 0xb6db9ea7 in QApplication::exec () from /usr/lib/libQtGui.so.4
#33 0xb756fbfd in initQtGui () from
/usr/lib/python2.4/site-packages/PyQt4/QtGui.so
#34 0xb7e6ccdd in PyCFunction_Call () from /usr/lib/libpython2.4.so.1.0
#35 0xb7ea5434 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
#36 0xb7ea6225 in PyEval_EvalCodeEx () from /usr/lib/libpython2.4.so.1.0
#37 0xb7ea62a3 in PyEval_EvalCode () from /usr/lib/libpython2.4.so.1.0
#38 0xb7ec0a98 in Py_CompileString () from /usr/lib/libpython2.4.so.1.0
#39 0xb7ec2168 in PyRun_SimpleFileExFlags () from
/usr/lib/libpython2.4.so.1.0
#40 0xb7ec284a in PyRun_AnyFileExFlags () from /usr/lib/libpython2.4.so.1.0
#41 0xb7ec8d1f in Py_Main () from /usr/lib/libpython2.4.so.1.0
#42 0x080485e2 in main ()
==

Am I doing something wrong or is it a bug?

TIA,
Serge