I am getting a fatal exception when scrolling data bound lists with more
lists items then there is visible space.

The view is shown ok, but if you try and scroll the view up or down using
your mouse or mouse wheel a fatal exception is raised in python.

I am using python 2.6 on windows using a pyside build from the Head on the
2nd Nov, installer available here:
http://www.syrris-support.com/Downloads/JMM/PySide-0.4.2.jmm.qt47.win32-py2.6.exe

This includes the bug fix I required:
(http://bugs.openbossa.org/show_bug.cgi?id=431)


This example demonstrates the issue (the declarative scrolling.py does work
with a larger dataset, but that uses strings)

view.qml contents:

import Qt 4.7

//![0]
ListView {
    width: 100; height: 100
    anchors.fill: parent

    model: myModel
    delegate: Rectangle {
        height: 25
        width: 100
        Text { text: model.modelData.name }
    }
}
//![0]

objectlistmodel.py contents:

from PySide import QtCore, QtGui, QtDeclarative

class DataObject(QtCore.QObject):
    nameChanged = QtCore.Signal()
    colorChanged = QtCore.Signal()

    def __init__(self, name):
        super(DataObject, self).__init__()
        self._name = name

    def get_name(self):
        return self._name

    def set_name(self, name):
        if self._name != name:
            self._name = name
            self.nameChanged.emit()

    name = QtCore.Property(str, fget=get_name, fset=set_name,
notify=nameChanged)

if __name__ == '__main__':
    import sys

    app = QtGui.QApplication(sys.argv)

    view = QtDeclarative.QDeclarativeView()
    view.setSource(QtCore.QUrl('view.qml'))

    dataList = []

    # add lots of objects
    index = 0
    while index < 50:
        dataList.append( DataObject("Item %d" % index) )
        index += 1

    view.show()

    ctxt = view.rootContext()
    ctxt.setContextProperty('myModel', dataList)

    sys.exit(app.exec_())


Has anybody else had this problem?  Any tips would be great.

Cheers,

Jon.
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to