[PyQt] how to insertRow() in a QAbstractListModel?

michael h michaelkenth at gmail.com
Thu Dec 10 04:16:29 GMT 2015


On Wed, Dec 9, 2015 at 1:24 PM, <c.buhtz at posteo.jp> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 2015-12-06 02:20 <c.buhtz at posteo.jp> wrote:
> > The signature (arguments/parameters) of the method doesn't have data
> > in. Where is the data to be inserted?




Not 100% sure about that method, but I believe the idea is that would
insert "empty" / "new" items (thus no data parameter).

In the past I've simply done:

model.beginInsertRows()
# code to modify underlying python list goes here, however you choose
# ....
model.endInsertRows()

Using these two methods causes the view(s) to requery the data
after endInsertRows() (given that you've implemented data() correctly)


- mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20151209/57615d03/attachment.html>


More information about the PyQt mailing list