[PyQt] How to use Model/View framework

IloChab ilochab at gmail.com
Tue May 8 19:51:04 BST 2007


I'm new in Qt programming.
I'm using Model/View framework to develop an editor for tree structures.
It shows tree data on a QTreeView that I link with setModel() to a different
QAbstractItemModel
for each set of data read from different files.

My problem is that on the first time that I call setModel() every thing
works fine, but each time I call a new setModel() for a new data-set
(without destroing QTreeView but also without doing new connect() to its
signals), I get a new duplicate calls to all my connected methods.
To be more clear:
I call once
        self.widget.connect(self.view, SIGNAL("clicked(const QModelIndex
&)"),
                            self.OnItemClicked)
At the first data-set loaded  self.OnItemClicked is called only once
At the second data-set loaded  self.OnItemClicked is called twice
and so on.
When I load a new data-set I create a new QAbstractItemModel object with the
new data and I call setModel() again on the old QTreeView object without
destroing it.

What's wrong in this?

Thanks in advance for any answer.
ciao!
Licia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20070508/61922d86/attachment.html


More information about the PyQt mailing list