[PySide] QStandardItemModel vs QAbstractItemModel

Frank Rueter | OHUfx frank at ohufx.com
Wed Jan 13 08:25:21 CET 2016


Thanks Florian,

with QATM I got up to the point of implementing custom background 
colours depending on what row the cell belongs to, and I noticed it was 
so insanely slow with only a tiny bit of data that I switched back to 
StandardItemModel for now, which is nice and fast - so far.
The slowness was due to me doing too many calls to the host application 
inside the data() method, and once I thought about how to do all that 
outside of data(), I realised the StandardItemModel would be much more 
suited for my approach.

So I decided to keep going with that until I hit a road block that may 
turn me back and reconsider, but hopefully that won't happen.

I have another issue now with item delegates but it's unrelated to this 
topic, so I will start a new thread shortly.

Cheers and thanks again Florian andSam for your input,

frank

On 13/01/16 8:15 pm, Florian Bruhin wrote:
> * Frank Rueter | OHUfx <frank at ohufx.com> [2016-01-13 09:32:04 +1300]:
>> in PySide there is no QVariant anyway, so that's all good.
>> I started yesterday trying to re-write what I already had going with
>> QStandardItemModel using QAbstractTableModel, but it seems there is a lot I
>> have to re-invent that QStandardTableModel already offered. I will keep
>> going for learning purposes but would be very interested in any other
>> opinions.
> I can only tell you about my experience with PyQt5 and
> QAbstractItemModel.
>
> Granted, it was only a few months after I started learning PyQt
> (or Qt, for that matter) - but it wasn't really pleasant.
>
> I tried to create a simple QAbstractItemModel based on a Python dict.
> You can find the latest source (before I ditched it) which worked (I
> think) here:
>
> https://github.com/The-Compiler/qutebrowser/blob/bc02df0bded309331220472a076ddac976afbec0/qutebrowser/models/basecompletion.py
>
> While developing it, every small mistake would give me a segfault
> somewhere inside Qt.
>
> I then discovered QStandardItemModel:
>
> https://github.com/The-Compiler/qutebrowser/commit/1eabbfbfcf9da58975c00dbc190e198c28473921
>
> The implementation using that turned out to be 300 lines of deleted
> code (compared to QSIM), noticably faster with some dozens of items
> (I'd dare to say almost double as fast), and probably more stable.
>
> I wrote some more specialized QAbstractItemModels since then and they
> were less of a pain, though.
>
> I can also recommend using the Qt5 modeltest to test if your model
> behaves properly.
>
> There's a PyQt5 port here which is standalone, but I don't think it
> works with PySide: https://github.com/bgr/PyQt5_modeltest
>
> I'm trying to integrate an updated version which works with
> PyQt4/PyQt5/PySide into pytest-qt:
>
> https://github.com/pytest-dev/pytest-qt/pull/63/files
>
> It shouldn't be too much work to get it to run standalone though, and
> it's sure worth the helpful information it gives you compared to
> painfully debugging stuff by hand ;)
>
> Florian
>

-- 
ohufxLogo 50x50 <http://www.ohufx.com> 	*vfx compositing 
<http://ohufx.com/index.php/vfx-compositing> | *workflow customisation 
and consulting <http://ohufx.com/index.php/vfx-customising>* *

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160113/711aa231/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ohufxLogo_50x50.png
Type: image/png
Size: 2666 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160113/711aa231/attachment.png>


More information about the PySide mailing list