<div dir="ltr"><div><div><div><div><div>Hi Florian,<br><br></div>Thanks again for the response.<br><br>>Wouldn't it be easier to just use a QStandardItemModel with<br>
>QStandardItems<br><br></div>Maybe. But I developed this code based on the simpletreemodel provided with PyQt Examples>Item Views. So continued with it. <br><br>>Does your model call begin* and end* appropriately?<br><br></div>I haven't used InsertChild at all in my code. I always add beginInsertRows before append child and endInsertRows after it's appended. In this line, the app is crashing.<br><br>>This seems wrong, your leaf items dont have any children.<br><br></div>I intentionally returned True. When the user expands the item I connect with the server and check for children and if it doesn't have any children, No children text is added to the tree.<br><br></div>Do you know how can I view the crash report in PyQt? Thanks<br><br><div><div><div><div><div><div><div><div><div><div class="gmail_extra"><div class="gmail_quote"><span dir="ltr"></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<span class="gmail-"><br>
> In the documentation of pytest-qt it's said that we need to add some items<br>
> and then test. Does it mean after appending few children at the root level?<br>
<br>
</span>Basically the modeltester tries to check if the model behaves correctly<br>
with whatever it does. It can test quite a few things without any<br>
modifications to the model, but ideally you should start the modeltester<br>
and then do various modifications to the model. In my code, I have<br>
various test cases for the model, and simply also activate the<br>
modeltester for all of them.<br>
<br>
Some comments about the code below:<br>
<span class="gmail-"><br>
> class TreeItem(object):<br>
>     def __init__(self, resource_id, name, parent_id, root_id,<br>
> parent=None, type="Folder"):<br>
>         self.resource_id = resource_id<br>
>         self.parent_id = parent_id<br>
>         self.root_id = root_id<br>
>         self.parentItem = parent<br>
>         <a href="http://self.name" rel="noreferrer" target="_blank">self.name</a>= name<br>
>         self.nodeType=type<br>
>         self.childItems = []<br>
<br>
</span>Wouldn't it be easier to just use a QStandardItemModel with<br>
QStandardItems?<br>
<span class="gmail-"><br>
>     def insertChild(self, pos, item):<br>
>         self.childItems.insert(pos, item)<br>
><br>
>     def appendChild(self, item):<br>
>         self.childItems.append(item)<br>
><br>
>     def removeChild(self, item):<br>
>         self.childItems.pop(0)<br>
<br>
</span>Does your model call begin* and end* appropriately?<br>
<br>
> class TreeModel(QAbstractItemModel):<br>
>     [...]<br>
><br>
>     def hasChildren(self,index):<br>
>         return True<br>
<br>
This seems wrong, your leaf items dont have any children.<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
Florian<br>
</font></span></blockquote></div><br></div></div></div></div></div></div></div></div></div></div></div>