Qt-interest Archive, July 2007
QFile and readReady() signal
Message 1 in thread
Hello
I am trying to read from Stdin by using QFile. From the archives I
see that readReady() has not been implemented for QFile. Is it
implemented in Qt 4.3? It is not working for me, but I may have made
a mistake.
If it is not implemented, what are the hacks? Is QTcpSocket still
the best bet? If so, what is the setup for the arguments of
connectToHost() ?
Thanks
r
--
[ signature omitted ]
Message 2 in thread
Hi!
> I am trying to read from Stdin by using QFile. From the archives I
> see that readReady() has not been implemented for QFile. Is it
> implemented in Qt 4.3? It is not working for me, but I may have made
> a mistake.
No, this is not implemented and I do not think it will be in the near
future. Too much trouble to make it cross-platform.
> If it is not implemented, what are the hacks? Is QTcpSocket still
> the best bet? If so, what is the setup for the arguments of
> connectToHost() ?
You do not need connectToHost(), but setSocketDescriptor(0) instead, or
setSocketDescriptor(fileno(stdin)) which is the same I believe. Or use
QSocketNotifier for getting notifications and QFile for reading.
But it will only work on Unix when stdin is a pipe or a socket. Maybe it
will work on Windows if you manage to pass real socket as stdin - I
heard it is possible. But it will not work if you redirect stdin as
this:
myapp < myfile
nor it will work on Windows if stdin is a pipe which is the case when
your application is started with QProcess or a shell pipe:
type myfile | myapp
Read recent thread on my post for more details:
http://lists.trolltech.com/qt-interest/2007-07/thread00838-0.html
I am currently trying to implement all the mentioned workarounds, but it
will take some time I think.
--
[ signature omitted ]