If possible, you should always reply to the listserv, so that everybody on
the list receives the response.

You are defining text_changed twice. The first time, you make it a Signal,
but then you overwrite it and make it a method.  If you instead have the
following:

    text_changed2=QtCore.Signal(list,str)

and

        self.emit(QtCore.SIGNAL("text_changed2(list,str)"),names,prefix)

then the signals are emitted properly.

Also, you could try using new-style signals and slots (defined at
http://developer.qt.nokia.com/wiki/Signals_and_Slots_in_PySide).  They are
much more Pythonic.

Ben

On Thu, Sep 22, 2011 at 6:15 PM, Ravi ..........! <[email protected]>wrote:

> Hi ,
>      here is my case where i am getting  Error:"Unknown type used to emit a
> signal: list"
>
> class LineEditCompleter(QtGui.QLineEdit):
>
>     text_changed=QtCore.Signal(list,str)
>     def __init__(self,parent=None):
>         QtGui.QLineEdit.__init__(self,parent)
>
> self.connect(self,QtCore.SIGNAL("textChanged(QString)"),self.text_changed)
>
>     def text_changed(self,text):
>         print text
>         allText=unicode(text)
>         prefix=allText.split(",")[-1].strip()
>
>         names=[]
>
>         for name in allText.split(","):
>             name=unicode(name).strip()
>             if name!="":
>                 names.append(name)
>         self.emit(QtCore.SIGNAL("text_changed(list,str)"),names,prefix)
>
>     def complete_name(self,text):
>         cursor_pos=self.cursorPosition()
>         before_text=unicode(self.text())[:cursor_pos]
>         after_text=unicode(self.text())[cursor_pos:]
>         prefix_len=len(before_text.split(",")[-1].strip())
>         self.setText("%s%s,
> %s"%(before_text[:cursor_pos-prefix_len],text,after_text))
>         self.setCursorPosition(cursor_pos-prefix_len+len(text)+2)
>
> class NameCompleter(QtGui.QCompleter):
>     def __init__(self,names=[],parent=None):
>         QtGui.QCompleter.__init__(self,names,parent)
>         self.names=names
>
>     def updateNames(self,names,completion_prefix):
>         _names=[]
>         for name in names:
>             if not self.names.__contains__(name):
>                 _names.append(name)
>
>         model=QtGui.QStringListModel(_names,self)
>         self.setModel(model)
>
>         self.setCompletionPrefix(completion_prefix)
>         if completion_prefix.strip() !="":
>             self.complete()
>
>
> def main():
>     app=QtGui.QApplication(sys.argv)
>     nameEditor=LineEditCompleter()
>     names=["ABC","DEF","AAAA"]
>     completer=NameCompleter(names)
>     completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
>
> QtCore.QObject.connect(nameEditor,QtCore.SIGNAL("text_changed(list,str)"),completer.updateNames)
>
> QtCore.QObject.connect(completer,QtCore.SIGNAL("activated(QString)"),nameEditor.complete_name)
>     completer.setWidget(nameEditor)
>     nameEditor.show()
>     sys.exit(app.exec_())
>
> if __name__=="__main__":
>     main()
>
>
>
>
> On Thu, Sep 22, 2011 at 4:52 PM, Ben Breslauer <[email protected]>wrote:
>
>> Well, that should work just fine.  Do you have an example that is not
>> working?  The following works for me, with PySide 1.0.6.
>>
>> Ben
>>
>> from PySide.QtCore import *
>>
>> def p(l, s):
>>     print l
>>     print s
>>
>> class s(QObject):
>>     sig = Signal(list,str)
>>
>> a = s()
>> a.sig.connect(p)
>>
>> a.sig.emit([1,2,3],'string')
>>
>>
>> On Thu, Sep 22, 2011 at 5:06 PM, Ravi ..........! 
>> <[email protected]>wrote:
>>
>>> Hi,
>>>      How to emit a custom signal which has 'list' as argument?
>>>
>>>                    text_changed=QtCore.Signal(list,str)
>>>
>>> _______________________________________________
>>> PySide mailing list
>>> [email protected]
>>> http://lists.pyside.org/listinfo/pyside
>>>
>>>
>>
>
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to