Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get QIODevice instance for stdin, stdout, stderr text streams in QtJambi?

Tags:

java

io

qt

qt-jambi

I would like to get QIODevice that represents standard IO streams (stdin, stdout, stderr) in QtJambi, so that i can get notified whenever a new line can be read or written.

like image 726
tzador Avatar asked Dec 15 '10 18:12

tzador


1 Answers

Well, if you just want to have QIODevice implementation for those, you could use something like

QFile stdin = new QFile();
stdin.open(0, new QIODevice.OpenMode(QIODevice.OpenModeFlag.ReadOnly));
QFile stdout = new QFile();
stdout.open(1, new QIODevice.OpenMode(QIODevice.OpenModeFlag.WriteOnly));
QFile stderr = new QFile();
stderr.open(2, new QIODevice.OpenMode(QIODevice.OpenModeFlag.WriteOnly));

(Not 100% sure about Java syntax as I have only used Qt/C++.)

But if you want to have notifications, this won't work. In fact, I doubt that anything would work unless you have stdin/stdout redirected to something that supports notifications, like a socket. In that case you'd use QAbstractSocket.setSocketDescriptor() method.

like image 153
Sergei Tachenov Avatar answered Nov 15 '22 02:11

Sergei Tachenov