[PyQt] signal with a (python) list

Phil Thompson phil at riverbankcomputing.com
Sat Sep 26 11:19:06 BST 2009


On Sat, 26 Sep 2009 07:06:47 -0300, Marcos Dione <mdione at grulic.org.ar>
wrote:
> question made on irc:
> 
> 20:03 < StyXman> can I define a pyqtSignal() with a parameter which is a
> list?
> 21:48 < david_boddie> StyXman: Define a signal to emit a list like this: 
>     abc = pyqtSignal("list")

Strictly speaking strings are interpreted as C++ types, so this should
be...

    abc = pyqtSignal(list)

...but it probably won't make a different as unknown C++ types fall back to
being handled as Python objects.

> 21:49 < david_boddie> StyXman: Define a signal to emit a list as one of
the
> 
>     parameters like this: abc = pyqtSignal("list", "int", "double")
> 
>     but it doesn't work:
> 
> QObject::connect: Cannot queue arguments of type 'list'
> (Make sure 'list' is registered using qRegisterMetaType().)
> 
>     playing a litle more I found the (partial) solution: as my list
>     contains
> unicode()s, I used QStringList:
> 
> foundSongs= pyqtSignal (QStringList)
> ...
> # pyqt4 cannot make this automatically
> self.foundSongs.emit (QStringList (filepaths))
> 
>     if the list were of something else, what should one do?

A complete, short test script that demonstrates the problem would help.

Phil


More information about the PyQt mailing list