[Kde-perl] Converting Qt4 QString to ordinary Perl string

Richard Dale rdale at foton.es
Wed Jun 17 14:22:20 CEST 2009


On Tuesday 16 June 2009 09:46:27 pm Chris Burel wrote:
> As I recall from when I looked at that version of the binding from a
> year ago, you have to go through a roundabout method to get the data
> out of the QString object.
>
> my $i = 0;
> my $perlStr = '';
> while( $i < $string->count() ) {
>     $perlStr .= chr( $string->at($i)->cell() );
>     $i++
> }
> print $perlStr;
> Hi there
>
> Very difficult.  This was one of the reasons the smoke-based PerlQt4
> project was started.  The link has already been posted.
One related point is that in PerlQt Qt3, a QByteArray was mapped onto a Perl 
string. But I found that was more trouble than it's worth in QtRuby, and so 
Qt::ByteArray is now a class, and not a string anymore.

-- Richard


More information about the Kde-perl mailing list