Converting Qt4 QString to ordinary Perl string

View: New views
9 Messages — Rating Filter:   Alert me  

Converting Qt4 QString to ordinary Perl string

by Adam Bar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello everyone,

My question is maybe stupid, but I am looking for few hours for the
solution - how to get string value from variable blessed QString?
my $str = 'string';
my $obj = QString($str);
# how to get 'string' from $obj ?

Methods like latin1(), ascii() are not defined in my perl binding.

I am using Perl Qt 4.004, Perl 5.8.8.

Thanks in advance!
Adam
_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl

Re: Converting Qt4 QString to ordinary Perl string

by Gary L. Greene, Jr.-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Friday 12 June 2009 03:37:53 pm Adam Bar wrote:

> Hello everyone,
>
> My question is maybe stupid, but I am looking for few hours for the
> solution - how to get string value from variable blessed QString?
> my $str = 'string';
> my $obj = QString($str);
> # how to get 'string' from $obj ?
>
> Methods like latin1(), ascii() are not defined in my perl binding.
>
> I am using Perl Qt 4.004, Perl 5.8.8.
>
> Thanks in advance!
> Adam
> _______________________________________________
> Kde-perl mailing list
> Kde-perl@...
> https://mail.kde.org/mailman/listinfo/kde-perl
Probably you'll have to marshal using some custom code in those bindings the
data from Qt using std::string QString::toStdString into Perl's SVpv. See  
http://doc.trolltech.com/4.5/qstring.html#toStdString for info on that
method.

--
Gary L. Greene, Jr.
Sent from: peorth.tolharadys.net
 00:02:57 up 39 days, 16:29,  3 users,  load average: 0.65, 0.66, 0.59
==========================================================================
Developer and Project Lead for the AltimatOS open source project
Volunteer Developer for the KDE open source project
See http://www.altimatos.com/ and http://www.kde.org/ for more information
==========================================================================

Please avoid sending me Word or PowerPoint attachments.


_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl

signature.asc (196 bytes) Download Attachment

Re: Converting Qt4 QString to ordinary Perl string

by Adam Bar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/6/13 Gary Greene <greeneg@...>
>
> Probably you'll have to marshal using some custom code in those bindings the
> data from Qt using std::string QString::toStdString into Perl's SVpv. See
> http://doc.trolltech.com/4.5/qstring.html#toStdString for info on that
> method.

There is no toStdString() in binding too. You say that I need to work
with binding code? It's not possible in ordinary Perl code? It is too
much for a newbie like me, thank you :)

A.
_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl

Re: Converting Qt4 QString to ordinary Perl string

by Gary L. Greene, Jr.-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Saturday 13 June 2009 05:16:56 am Adam Bar wrote:

> 2009/6/13 Gary Greene <greeneg@...>
>
> > Probably you'll have to marshal using some custom code in those bindings
> > the data from Qt using std::string QString::toStdString into Perl's SVpv.
> > See http://doc.trolltech.com/4.5/qstring.html#toStdString for info on
> > that method.
>
> There is no toStdString() in binding too. You say that I need to work
> with binding code? It's not possible in ordinary Perl code? It is too
> much for a newbie like me, thank you :)
>
> A.
> _______________________________________________
> Kde-perl mailing list
> Kde-perl@...
> https://mail.kde.org/mailman/listinfo/kde-perl
If they are missing that function in their code, then, those bindings are old
and don't support current Qt. Which version of Qt are these bindings built
against?

--
Gary L. Greene, Jr.
Sent from: peorth.tolharadys.net
 11:41:53 up 40 days,  4:07,  3 users,  load average: 0.68, 0.73, 0.64
==========================================================================
Developer and Project Lead for the AltimatOS open source project
Volunteer Developer for the KDE open source project
See http://www.altimatos.com/ and http://www.kde.org/ for more information
==========================================================================

Please avoid sending me Word or PowerPoint attachments.


_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl

signature.asc (196 bytes) Download Attachment

Re: Converting Qt4 QString to ordinary Perl string

by Eric Wilhelm-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

# from Adam Bar
# on Friday 12 June 2009 15:37:

>My question is maybe stupid, but I am looking for few hours for the
>solution - how to get string value from variable blessed QString?
>my $str = 'string';
>my $obj = QString($str);
># how to get 'string' from $obj ?
>
>Methods like latin1(), ascii() are not defined in my perl binding.
>
>I am using Perl Qt 4.004, Perl 5.8.8.

Hi Adam,

Where did you get this Qt.pm?  I think you must be running the non-smoke
QtCore+QtGUI distros.

  http://search.cpan.org/~vadiml/QtCore-4.004/

I haven't looked at that much except to determine that the API was
fabricated from generated XS code and seems to require that every
string be constructed using a QString() function -- which is not very
perlish.  The developer also does not seem to respond to any of my
mail.

On the other hand:

  http://code.google.com/p/perlqt4/

This intends to be a successor to the old PerlQt (3) and will work much
like it.  Plus, the maintainers of this code *are* on this list.  
However, it isn't on the CPAN yet.

--Eric
--
If the above message is encrypted and you have lost your pgp key, please
send a self-addressed, stamped lead box to the address below.
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------
_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl

Re: Converting Qt4 QString to ordinary Perl string

by Chris Burel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

On Sun, Jun 14, 2009 at 10:51 AM, Eric
Wilhelm<ewilhelm@...> wrote:

> # from Adam Bar
> # on Friday 12 June 2009 15:37:
>
>>My question is maybe stupid, but I am looking for few hours for the
>>solution - how to get string value from variable blessed QString?
>>my $str = 'string';
>>my $obj = QString($str);
>># how to get 'string' from $obj ?
>>
>>Methods like latin1(), ascii() are not defined in my perl binding.
>>
>>I am using Perl Qt 4.004, Perl 5.8.8.
>
> Hi Adam,
>
> Where did you get this Qt.pm?  I think you must be running the non-smoke
> QtCore+QtGUI distros.
>
>  http://search.cpan.org/~vadiml/QtCore-4.004/
>
> I haven't looked at that much except to determine that the API was
> fabricated from generated XS code and seems to require that every
> string be constructed using a QString() function -- which is not very
> perlish.  The developer also does not seem to respond to any of my
> mail.
>
> On the other hand:
>
>  http://code.google.com/p/perlqt4/
>
> This intends to be a successor to the old PerlQt (3) and will work much
> like it.  Plus, the maintainers of this code *are* on this list.
> However, it isn't on the CPAN yet.
>
> --Eric
> --
> If the above message is encrypted and you have lost your pgp key, please
> send a self-addressed, stamped lead box to the address below.
> ---------------------------------------------------
>    http://scratchcomputing.com
> ---------------------------------------------------
> _______________________________________________
> Kde-perl mailing list
> Kde-perl@...
> https://mail.kde.org/mailman/listinfo/kde-perl
>
_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl

Re: Converting Qt4 QString to ordinary Perl string

by Richard Dale-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
https://mail.kde.org/mailman/listinfo/kde-perl

Re: Converting Qt4 QString to ordinary Perl string

by Gary L. Greene, Jr.-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
> 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.)

--
Gary L. Greene, Jr.
Sent from: peorth.tolharadys.net
 08:33:06 up 45 days, 59 min,  3 users,  load average: 0.39, 0.58, 0.61
==========================================================================
Developer and Project Lead for the AltimatOS open source project
Volunteer Developer for the KDE open source project
See http://www.altimatos.com/ and http://www.kde.org/ for more information
==========================================================================

Please avoid sending me Word or PowerPoint attachments.


_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl

signature.asc (196 bytes) Download Attachment

Re: Converting Qt4 QString to ordinary Perl string

by Richard Dale-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
> > 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
_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl