[PySide] PySide calls wrong emit() inside class
Robert Schilling
Fun_Extra_300 at gmx.net
Tue Jul 23 18:36:20 CEST 2013
Hi Nathan,
Thanks for the answer, but this doesn't work either:
from PySide import QtCore
from PySide.QtCore import QObject
class Foo(QObject):
def __init__(self):
QObject.__init__(self)
self.sig = QtCore.Signal(str)
def emit(self):
self.sig.emit("1")
x = Foo()
x.emit()
This triggers the following error:
self.sig.emit("1")
AttributeError: 'PySide.QtCore.Signal' object has no attribute 'emit'
Having the classwide signal, this is from the type ySide.QtCore.Signalnstance.
Robert
Gesendet: Dienstag, 23. Juli 2013 um 18:31 Uhr
Von: "Nathan Smith" <nathanjsmith at gmail.com>
An: "Robert Schilling" <Fun_Extra_300 at gmx.net>
Cc: pyside at qt-project.org
Betreff: Re: [PySide] PySide calls wrong emit() inside class
Hi Robert,
You've created your signal at the class level, so it is shared by all instances of Foo. What you want is the signal at the object level, so each instance holds its own signal. Do so by creating the signal in the __init__ method.
def __init__(self):
QObject.__init__(self)
self.sig = QtCore.signal(str)
Nathan
On Jul 23, 2013 11:09 AM, "Robert Schilling" <Fun_Extra_300 at gmx.net> wrote:Hi @ all,
Consider following example:
from PySide import QtCore
from PySide.QtCore import QObject
class Foo(QObject):
sig = QtCore.Signal(str)
def __init__(self):
QObject.__init__(self)
def emit(self):
self.sig.emit("1")
x = Foo()
x.emit()
This example doesn't work. When calling self.sig.emit("1") actually Foo.emit() is invoked.
Testing this example works with PyQt (that's what I'm migrating from).
Am I doing something wrong? How can I avoid this?
Regards Robert
_______________________________________________
PySide mailing list
PySide at qt-project.org[PySide at qt-project.org]
http://lists.qt-project.org/mailman/listinfo/pyside
More information about the PySide
mailing list