[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Next SIP and PyQt4 Releases -> QDataWidgetMapper
From:       Phil Thompson <phil () riverbankcomputing ! co ! uk>
Date:       2007-09-27 8:36:35
Message-ID: 200709270936.35109.phil () riverbankcomputing ! co ! uk
[Download RAW message or body]

On Wednesday 26 September 2007, Nicolas Girard wrote:
> 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.

Assuming a UNIX filesystem, the data model only has one row. If you root the 
mapper at a different part of the model by adding the following to 
setModel()...

    self.dwm.setRootIndex(model.index("/etc"))

...you get a better idea of what's going on.

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic