Hey,
I'm trying to do same pretty easy application for meamo 5 using QT (right now in PythonQT). I came to strange bugs in 4.5.3 version so I've upgraded to 4.6.2. Old errors disappeared however new one appeared.
Maybe someone can provide some help or suggestion how to move forward.
Here is complete story:
with such libs:
Attached code looks like this:Code:[sbox-FREMANTLE_X86: ~] > dpkg -l python2.5-qt4* | grep ii ii python2.5-qt4-common 4.7-maemo7 Shared files for PyQt4 ii python2.5-qt4-core 4.7-maemo7 Python bindings for Qt4 Core components. ii python2.5-qt4-dbus 4.7-maemo7 Python bindings for Qt dbus mainloop. ii python2.5-qt4-gui 4.7-maemo7 Python bindings for Qt4 Core components. [sbox-FREMANTLE_X86: ~] > dpkg -l libqt* | grep ii ii libqt4-core 4.5.3~git20090723-0maemo6+0m5 Qt 4 core module ii libqt4-gui 4.5.3~git20090723-0maemo6+0m5 Qt 4 GUI module
As you can see there is something wrong with checkboxes
So I've updated to newest version of qt and pyton-qt
Now I've following libs:
And application (at least checkbox) looks much better:Code:[sbox-FREMANTLE_X86: ~] > dpkg -l python2.5-qt4* | grep ii ii python2.5-qt4-common 4.7.3-maemo2 Shared files for PyQt4 ii python2.5-qt4-core 4.7.3-maemo2 Python bindings for Qt4 Core components. ii python2.5-qt4-dbus 4.7.3-maemo2 Python bindings for Qt dbus mainloop. ii python2.5-qt4-gui 4.7.3-maemo2 Python bindings for Qt4 Core components. [sbox-FREMANTLE_X86: ~] > dpkg -l libqt* | grep ii ii libqt4-core 4.6.2~git20100310-0maemo1+0m5 Qt 4 core module ii libqt4-gui 4.6.2~git20100310-0maemo1+0m5 Qt 4 GUI module
However the same code that was previously working, with new libs doesn't. Once editor has been open - its widgets doesn't work (looks like they doesn't get events or maybe there is some problem with position translation).
I've no idea what I'm doing wrong and why code that was working now doesn't.
Thanks
Kasper
PS. Screenshots are taken from scratchbox but on real device it looks exactly the same
_________________________ test_case.py ________________
Code:import sys from PyQt4 import QtCore, QtGui from PyQt4.QtCore import * from PyQt4.QtGui import * class MyForm(QtGui.QWidget): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) list_data = ["item1","item2","item3","item4","item5"] lm = MyListModel(list_data,self) self.lv = QListView() self.lv.setModel(lm) # print i self.mdelegate=MyDelegate(self.lv) self.lv.setItemDelegate(self.mdelegate) # layout layout = QVBoxLayout() layout.addWidget(self.lv) self.setLayout(layout) class MyListModel(QAbstractListModel): def __init__(self, datain, parent=None, *args): QAbstractListModel.__init__(self, parent, *args) self.listdata = datain def rowCount(self, parent=QModelIndex()): return len(self.listdata) def data(self, index, role): if role==Qt.CheckStateRole: return Qt.Checked if index.isValid() and role == Qt.DisplayRole: return QVariant(self.listdata[index.row()]) else: return QVariant() def flags(self, index): return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsDragEnabled |QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | Qt.ItemIsEditable class MyDelegate(QStyledItemDelegate): def __init__(self, parent): QStyledItemDelegate.__init__(self, parent) self.editorState=False def createEditor(self, parent, option, index): editor=MyEditor(parent) return editor def sizeHint (self, option, index): return QStyledItemDelegate.sizeHint(self, option, index)+QSize(0, 0) def setEditorData( self, editor, index ): pass def updateEditorGeometry( self, editor, option, index ): editor.setGeometry(option.rect) class MyEditor(QtGui.QWidget): def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self.button = QtGui.QPushButton("Press me") layout = QVBoxLayout(parent) layout.addWidget(self.button) self.setLayout(layout) QtCore.QObject.connect(self.button, QtCore.SIGNAL("clicked()"), self.echo) def setValue(self, value): pass def echo(self): print "has been clicked" if __name__ == "__main__": app = QtGui.QApplication(sys.argv) myapp = MyForm() myapp.show() sys.exit(app.exec_())



Reply With Quote




