t-artistik / qtscriptgenerator

Automatically exported from code.google.com/p/qtscriptgenerator
0 stars 0 forks source link

QByteArray: Bindings for data() and constData() is not generated #42

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Bindings for data() and constData() is not generated for QByteArray class.
This makes it impossible to access the content of the QByteArray object as
a string from scripts. As a result, I cannot also use QFile from scripts as
it returns QByteArray.

What is the expected output? What do you see instead?
A way to access the contents of QByteArray as a string from scripts.

What version of the product are you using? On what operating system?
Qt 4.5 with latest generator git snapshot

Please provide any additional information below.

Original issue reported on code.google.com by nhasan%n...@gtempaccount.com on 31 Mar 2009 at 4:36

GoogleCodeExporter commented 8 years ago
You can use this:
QByteArray.prototype.toString = function()
{
   ts = new QTextStream( this, QIODevice.ReadOnly );
   return ts.readAll();
}

Something like this should be defined by default I think.

Original comment by ian.mon...@gmail.com on 31 Mar 2009 at 6:41

GoogleCodeExporter commented 8 years ago
Thanks Ian for the suggestion.

This gave me the idea to use QTextStream as a QFile wrapper:

    var file = new QFile( name );
    file.open( new QIODevice.OpenMode( QIODevice.ReadOnly ) );
    var stream = new QTextStream( file );
    while ( !stream.atEnd() )
    {
    }

Original comment by nhasan%n...@gtempaccount.com on 31 Mar 2009 at 8:37