[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bindings
Subject:    Re: [Kde-bindings] C#, Qyoto, Qt - How to read output from QProcess?
From:       Arno Rehn <arno () arnorehn ! de>
Date:       2010-02-19 18:42:27
Message-ID: 201002191942.28005.arno () arnorehn ! de
[Download RAW message or body]

On Friday 19 February 2010 11:06:39 Richard Dale wrote:
> On Friday 19 February 2010 06:02:47 am linuxoidoz@yahoo.com.au wrote:
> > All I've done was to move
> > 
> > proc = new QProcess(this);
> > 
> > from the MainWindow class constructor to the slot and it's working now,
> > that is on readyReadStandardOutput(), it writes my text into a QTextEdit
> > 
> > box. But how can I output the process output into the QTextEdit? This:
> >                [Q_SLOT]
> >                private void updateLog() {
> >                
> >                        QByteArray data = proc.ReadAllStandardOutput();
> >                        QTextCodec codec =
> >                        QTextCodec.CodecForUtfText(data); string str =
> >                        codec.ToUnicode(data);
> >                        txtEdit.Append(str);
> >                
> >                }
> > 
> > only crashes the app with "System.MemberAccessException: Cannot create an
> > instance of Qyoto.QTextCodec because it is an abstract class". I used the
> > Qt C++ example and modified it to C#. There are many examples which show
> > you can cast byte array type to string with QString(byteArray), but
> > there's no QString in Qyoto, and (String)byteArray complains it can't
> > convert QBytaArray to string. I'd appreciate your help. Thank you.
> 
> We've added a QByteArray.ToArray() method to convert it to a byte[], which
> you can then convert to a string with something like
> System.Text.Encoding.ASCII.GetString.
Or simply use QByteArray.ConstData() which should give you a C# string 
directly.

-- 
Arno Rehn
arno@arnorehn.de
_______________________________________________
Kde-bindings mailing list
Kde-bindings@kde.org
https://mail.kde.org/mailman/listinfo/kde-bindings
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic