[PyQt] RegExp and QString

Giovanni Bajo rasky at develer.com
Thu Feb 7 19:07:21 GMT 2008


On 2/11/2008 7:22 AM, Tiago Maluta wrote:

> Following Assistant (for C++) documentation about QString split method I 
> saw:
> 
> str = "Now: this sentence fragment.";
> list = str.split(QRegExp("\\b"));
> // list: [ "", "Now", ": ", "this", " ", "sentence", " ", "fragment", "." ]

Not really... there's a missing QString() construction somewhere.

> Now, I with python I tried, a simple example:
> 
> 
>  line = p.readline()
>  sline = line.split(QtCore.QRegExp("[A-Z]+"))
> 
> With this code I got: TypeError: PyQt expected a character buffer object.

It would work if you first converted the output of readline() to QString.
-- 
Giovanni Bajo


More information about the PyQt mailing list