[PyQt] PyQt5.6 with Python 3.5 Crash

Florian Bruhin me at the-compiler.org
Fri May 19 13:24:36 BST 2017


Hi,

On Fri, May 19, 2017 at 05:21:28PM +0530, Rathinam Signup wrote:
> In the documentation of pytest-qt it's said that we need to add some items
> and then test. Does it mean after appending few children at the root level?

Basically the modeltester tries to check if the model behaves correctly
with whatever it does. It can test quite a few things without any
modifications to the model, but ideally you should start the modeltester
and then do various modifications to the model. In my code, I have
various test cases for the model, and simply also activate the
modeltester for all of them.

Some comments about the code below:

> class TreeItem(object):
>     def __init__(self, resource_id, name, parent_id, root_id,
> parent=None, type="Folder"):
>         self.resource_id = resource_id
>         self.parent_id = parent_id
>         self.root_id = root_id
>         self.parentItem = parent
>         self.name= name
>         self.nodeType=type
>         self.childItems = []

Wouldn't it be easier to just use a QStandardItemModel with
QStandardItems?

>     def insertChild(self, pos, item):
>         self.childItems.insert(pos, item)
> 
>     def appendChild(self, item):
>         self.childItems.append(item)
> 
>     def removeChild(self, item):
>         self.childItems.pop(0)

Does your model call begin* and end* appropriately?

> class TreeModel(QAbstractItemModel):
>     [...]
> 
>     def hasChildren(self,index):
>         return True

This seems wrong, your leaf items dont have any children.

Florian

-- 
https://www.qutebrowser.org  | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072  | https://the-compiler.org/pubkey.asc
         I love long mails!  | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170519/738683d1/attachment.sig>


More information about the PyQt mailing list