[PySide] Trouble understanding QStandardItemModel

Tony Barbieri greatrgb at gmail.com
Thu Apr 17 15:16:14 CEST 2014


You could try model.itemFromIndex(model.index(0, 0)), that should return
the item.  You also don't need to use the invisibleRootItem to append a
row, you should be able to just call model.appendRow(QStandardItem("test")).


On Thu, Apr 17, 2014 at 2:20 AM, S. Champailler <schampailler at skynet.be>wrote:

> Tried your code, same error.
>
> I'm just wondering if model.data(...) default role is not preventing
> something
> to work in QStandardItemModel....
>
> Stefan
>
> > Le 16 avril 2014 à 23:08, Jonas Thiem <jonasthiem at googlemail.com> a
> écrit :
> >
> >
> > Hi,
> >
> > Trying to understand QStandardItemModel I came up with this:
> >
> > from PySide.QtCore import *
> > from PySide.QtGui import *
> >
> > model = QStandardItemModel()
> > model.invisibleRootItem().appendRow(QStandardItem("test"))
> > assert(model.rowCount() == 1)
> > assert(model.columnCount() == 1)
> > mIndex = model.createIndex(0, 0)
> > print(model.data(model.index(0, 0)))
> > assert(model.itemFromIndex(mIndex) != None)
> >
> > The last assert fails with PySide 1.2.1 and Python 3.3.5 on Windows 7.
> > Is that supposed to happen? What would be the proper approach to
> > simply get the first most topleft item in a QStandardItemModel?
> >
> > Regards,
> > Jonas Thiem
> > _______________________________________________
> > PySide mailing list
> > PySide at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/pyside
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside
>



-- 
-tony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20140417/7586ff6d/attachment.html>


More information about the PySide mailing list