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

Richard Dale richard_dale at tipitina.demon.co.uk
Thu Jun 18 18:27:30 CEST 2009


On Thursday 18 June 2009 04:34:05 pm Gary Greene wrote:
> On Wednesday 17 June 2009 05:22:20 am Richard Dale wrote:
> > 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
> > _______________________________________________
> > Kde-perl mailing list
> > Kde-perl at kde.org
> > https://mail.kde.org/mailman/listinfo/kde-perl
>
> As long as there is a way to convert TO a string for QByteArrays that
> shouldn't be too much of a problem. (Yes, I've run into code that needs
> that.)
Yes that's right - I added a 'to_s()' method in Ruby to do that by calling 
constData() on the QByteArray, and so you'll need to add a custom equivalent 
for Perl.

-- Richard


More information about the Kde-perl mailing list