[Kde-bindings] C#, Qyoto, Qt - How to read output from QProcess?

linuxoidoz at yahoo.com.au linuxoidoz at yahoo.com.au
Fri Feb 19 07:04:56 UTC 2010


It turns out it's not that simple. I have a QMessageBox.About(this, "About", "Converting"); inside the updateLog() to check if it gets called by Connect(proc, SIGNAL("readyReadStandardOutput()"), this, SLOT("updateLog()"));.

1. If I do 

proc.Start("ffmpeg", "-i video.avi video mp4");

it converts the video file without a problem, no errors, but the updateLog() slot never runs, that is readyReadStandardOutput() probably doesn't trigger - no message pops up.

2. If I do

proc.Start("ffmpeg", "-help");

it crashes with "System.MemberAccessException: Cannot create an instance of Qyoto.QTextCodec because it is an abstract class" - but before it crashes the message box pops up, that is the readyReadStandardOutput() is definitely triggered.

Any thoughts? Thank you.

------------------  Original Message  ------------------
Subject: Re: [Kde-bindings] C#, Qyoto, Qt - How to read output from QProcess?
Date: Fri, 19 Feb 2010
From: linuxoidoz at yahoo.com.au
To: kde-bindings at kde.org

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



More information about the Kde-bindings mailing list