[PyQt] How does one add an item to QListView?
Florian Bruhin
me at the-compiler.org
Thu Sep 10 05:26:20 BST 2015
* Brandon Keith Biggs <brandonkeithbiggs at gmail.com> [2015-09-10 05:06:40 +0200]:
> How does one add an item to a QListView?
> I have searched through the
> QListView C++ Documentation, <http://doc.qt.io/qt-5/qlistview.html>
> but there is no addItem or setItems method.
> I have found Qt3 and Qt4 examples, but no Qt5 or PyQt5 examples.
> If someone could please point me in the right direction, it would be
> amazing!
A view in Qt is just that: A view. It (mostly) doesn't manage the
underlying data.
You provide data by setting a model on it, e.g. a QStandardItemModel
or your own QAbstractListModel subclass.
For simpler things, it might be easier to use QListWidget instead,
which is basically a QListView with integrated model (and has a
addItem method).
Florian
--
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150910/b1960739/attachment.sig>
More information about the PyQt
mailing list