[PySide] What can be returned from a slot?

Yann Lanthony yann.lanthony at gmail.com
Sun Jan 13 12:06:45 CET 2013


Strange,
I'm pretty sure of the "QVariant" though, because I'm using it to expose a
custom model that inherits QAbstractListModel as a Qt Property like this :

model = QtCore.Property("QVariant", getModel, constant=True)

and it's working fine.
I've just tested to create a slot like yours (creating and returning an
instance of my custom model) in my minimal app and I have no segfault.
Maybe it's because you don't give your  TargetListModel a parent. So you
create it and immediately return it but no one takes its ownership and it's
deleted to soon. This might explain the segfault.

What if you try to add this ? :

class TargetListModel(QtCore.QAbstractListModel):

def __init__(self, parent, targets):

QtCore.QAbstractListModel.__init__(self, parent)


@QtCore.Slot(int, int, result="QVariant")

def image_targets(self, frame, cam):

return TargetListModel(self,

[{'x': 100, 'y': 100},

{'x': 200, 'y': 200},

])



2013/1/13 Yosef Meller <yosefmel at post.tau.ac.il>

> **
>
> On Sunday 13 January 2013 11:02:55 Yann Lanthony wrote:
>
> > I think it should be :
>
> > @QtCore.Slot(int, int, result="QVariant")
>
>
>
> No, this just gives a segfault.
>
>
>
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20130113/74de1da0/attachment.html>


More information about the PySide mailing list