Ok, I have to post my code because your suggest doesn't work (probably i miss something).<br><br> <br>class DomModel(QtCore.QAbstractItemModel):<br> def __init__(self, document, parent = None):<br> QtCore.QAbstractItemModel.__init_
_(self, parent)<br><br> self.domDocument = document ##this is a QDomDocument object<br><br> self.rootItem = DomItem(self.domDocument, 0)<br><br> ## some useful methods<br> def columnCount(self, parent):
<br> def data(self, index, role):<br> def headerData(self, section, orientation, role):<br> def index(self, row, column, parent):<br> def parent(self, child):<br> def rowCount(self, parent):<br> def findNodeByTagNameID(self,tagName,id):
<br> def validateDom(self,nodo):<br><br><br> def removeRows(self,arow,count,parent):<br> <br> self.beginRemoveRows(parent,arow,arow+count-1)<br> <br> for ii in range(count): <br> ##code for removing a row from QDomDocument here
<br> <br> self.endRemoveRows()<br> return True<br> <br><br><br>This is my model class. When i remove a row the qtreeview repaint the tree but the row deleted isn't the one i've selected.<br>
example:<br><br>the treeview show:<br><br>document<br> element1<br> element2<br> element3<br><br>pick elements2 for removing.<br><br>treeview update after removing but show:<br><br>document<br> element1<br>
element2<br><br><br><br>Now, if i do:<br><br>print qtreeview.model().domDocument.toString() <br><br>the result is:<br><br>document<br> element1<br> element3<br><br>so, the model is changed right. the removed element is the one that i picked.
<br><br>Any idea?<br><br><br>p.s. <span onclick="dr4sdgryt(event)">apologise for my english...hope it's </span><span onclick="dr4sdgryt(event)">understandable</span><br> <br><br><br><br><div><span class="gmail_quote">2006/9/8, Andreas Pakulat <
<a href="mailto:apaku@gmx.de">apaku@gmx.de</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On 08.09.06 10:38:51, Oscar Cossu wrote:
<br>> thank you for the advice, I have read the doc again (and again and again).<br>> Now, I use a QTreeView ,what i have to do ?<br>><br>> QTreeView::rowsAboutToBeRemoved(param)<br>><br>> treeviewobj.model
().removeRow(param)<br>><br>> QTreeView::rowsRemoved(param)<br><br>No.<br><br>> or just call removeRow() that call itself beginRemoveRow and endRemoveRow ?<br><br>Well, you said you have your own model, don't you? In there you've got
<br>your removeRows() function. If that one is implemented by doing<br>something like<br><br>beginRemoveRows(parent(), beginRow, endRow);<br><code that deletes the stuff from the underlying data, i.e. the xml tree><br>
endRemoveRows();<br><br>Then you're done. You can now use the model's removeRows() function to<br>remove rows. The same works for columns.<br><br>If it still doesn't work for you, please consider posting the important<br>
parts of your model. (i.e. leave out the data, index, parent, *count<br>functions).<br><br>Andreas<br><br>> 2006/9/7, Andreas Pakulat <<a href="mailto:apaku@gmx.de">apaku@gmx.de</a>>:<br>> ><br>> >On
07.09.06 16:44:23, Oscar Cossu wrote:<br>> >> Hy all, I set the model of a QTreeView with an object that is a<br>> >subclass of<br>> >> QAbstractItemModel.<br>> >> When I change the model (ex. deleting a row) and emit layoutChanged()
<br>> >> signal, the treeModel should update the view, but errors occur.<br>> ><br>> >Read the Qt documentation on model/view again. You shouldn't use<br>> >layoutChanged() but call QAbstractItemModel::beginRemoveRows() and
<br>> >::endRemoveRows (the same for inserting rows).<br>> ><br>> >Andreas<br>> ><br>> >--<br>> >Accent on helpful side of your nature. Drain the moat.<br>> ><br>> >_______________________________________________
<br>> >PyKDE mailing list <a href="mailto:PyKDE@mats.imk.fraunhofer.de">PyKDE@mats.imk.fraunhofer.de</a><br>> ><a href="http://mats.imk.fraunhofer.de/mailman/listinfo/pykde">http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
</a><br>> ><br><br>> _______________________________________________<br>> PyKDE mailing list <a href="mailto:PyKDE@mats.imk.fraunhofer.de">PyKDE@mats.imk.fraunhofer.de</a><br>> <a href="http://mats.imk.fraunhofer.de/mailman/listinfo/pykde">
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde</a><br><br><br>--<br>Keep it short for pithy sake.<br><br>_______________________________________________<br>PyKDE mailing list <a href="mailto:PyKDE@mats.imk.fraunhofer.de">
PyKDE@mats.imk.fraunhofer.de</a><br><a href="http://mats.imk.fraunhofer.de/mailman/listinfo/pykde">http://mats.imk.fraunhofer.de/mailman/listinfo/pykde</a><br></blockquote></div><br>