[PyQt] PyQt4 question related to QVariant

Mark Summerfield list at qtrac.plus.com
Sun Jul 5 07:51:44 BST 2009


On 2009-07-04, Detlev Offenbach wrote:
> Hi,
>
> I would like to store a QModelIndex instance in a QVariant in one
> place of my code and retrieve this back out of the variant somewhere
> else.
>
> How do I do that. PyQt4.QtCore.QVariant seems to be missing the
> setValue() method.
>
> Regards,
> Detlev

If you're going to store anything it ought to be a
QPersistentModelIndex.

Here's what the QModelIndex docs say
"Note: Model indexes should be used immediately and then discarded. ...
If you need to keep a model index over time use a QPersistentModelIndex."


-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "C++ GUI Programming with Qt 4" - ISBN 0132354160




More information about the PyQt mailing list