[PyQt] Next SIP and PyQt4 Releases -> QDataWidgetMapper

Nicolas Girard nicolas.girard at nerim.net
Wed Sep 26 23:16:20 BST 2007


On mercredi 26 septembre 2007, Phil Thompson wrote:
> The next releases of SIP and PyQt4 will be made in the next few days. Both
> are maintenance releases (ie. mostly bug fixes). If anybody thinks there is
> something that still needs fixing then now is the time to shout.
>

Hi Phil,
a few days ago I submitted a problem in message titled "QTreeView and 
QDataWidgetMapper". Could you please have a look to the (almost) same code 
again:

#!/usr/bin/python
from PyQt4 import QtCore,QtGui
import sys

class Window(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.tree = QtGui.QTreeView(self)
        self.lineEdit = QtGui.QLineEdit(self)
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.lineEdit)
        layout.addWidget(self.tree)
        self.setLayout(layout)
    def setModel(self,model):
        self.tree.setModel(model)
        self.dwm = QtGui.QDataWidgetMapper(self)
        self.dwm.setModel(model)
        self.dwm.addMapping(self.lineEdit, 0)
        self.connect(self.tree.selectionModel(),
            QtCore.SIGNAL("currentChanged(QModelIndex,QModelIndex)"),
            self.dwm, QtCore.SLOT("setCurrentModelIndex(QModelIndex)"))
        self.connect(self.tree.selectionModel(),
            QtCore.SIGNAL("currentChanged(QModelIndex,QModelIndex)"),
            self.slot)
    def slot(self,ix):
        print "CHANGED"

if __name__=="__main__":
    app=QtGui.QApplication(sys.argv)
    window=Window()
    model = QtGui.QDirModel()
    window.setModel(model)
    window.show()
    sys.exit(app.exec_())

I'd expect the lineEdit contents to be refreshed each time the treeview's 
selection changes (i.e. each time "CHANGED" is printed out); unfortunately it 
doesn't work.

I'm not sure, but it might be a PyQt-related issue.

Nicolas



More information about the PyQt mailing list