[Kde-bindings] Qyoto: Reading from stdin from a gui-application

Christoph Spielmann spielc at gmail.com
Sun May 18 09:36:57 UTC 2008


Hi everybody!

I'm working on an application which receives commands from stdin. After 
a bit of googleing i found the following solution for doing that using 
qt (the original example code was not for qyoto but i assumed it would 
work similarly so i just adepted the code...):

|...
public QFile stdin;
public QSocketNotifier stdinNot;
...
this.stdin=new QFile();
this.stdin.Open(0,(int) QIODevice.OpenModeFlag.ReadOnly); //open stdin for reading

this.stdinNot=new QSocketNotifier(0,QSocketNotifier.TypeOf.Read);
QObject.Connect(this.stdinNot, Qt.SIGNAL("activated(int)"),this,Qt.SLOT("DataReadyOnStdin()"));

...
[Q_SLOT]
public void DataReadyOnStdin() {
    Console.WriteLine(this.stdin.Read("",255L));
}
...
|


i have to use both a QSocketNotifier and QFile to get notified as soon 
as we have acitvity on stdin, because according to the QT-documentation 
QFile does NOT emit the readyRead() signal (which is a shame in my eyes 
but okey, i could live with the above solution if it would work... ;) ).

As soon as i enter something to stdin the activiated(int) signal gets 
emitted as expected but as soon as i actually try to read from stdin 
using the QFile-object stdin i get this:

Cannot handle 'qint64' as argument to QIODevice::read

So what is the correct way to read data from stdin within a 
qyoto-gui-application? I'm open for all suggestion as i am kinda out of 
ideas how to solve this task!

Thanks in advance,

Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20080518/79f70a79/attachment.html>


More information about the Kde-bindings mailing list