[Qt-interest] Hooking up a QIODevice to a unix pipe

qzvjtml02 at sneakemail.com qzvjtml02 at sneakemail.com
Thu Jul 9 18:42:35 CEST 2009


Chris, you can just print to stdout. For instance, take this simple  
program:

---------------------------------------
#include <iostream>

using namespace std;

int main()
{
         for (int i = 0; i < 10; i++)
         {
                 cout << i << endl;
         }
         return 0;
}
---------------------------------------

If you were to compile this and run it like so:

./a.out | grep 2

It would print the two that was printed by a.out and nothing else. I  
know... sucky example, but you get the idea.

	Hope that helps!

		Kyle Fazzari

On Jul 9, 2009, at 9:29 AM, Chris chris1.noreply-at-googlemail.com |Qt- 
interest| wrote:

> Hi, I'm writing a custom QIODevice to get data from a server (via a
> socket). I want to be able to read data from my custom IODevice and
> output it to a unix pipe, such that on the command line I can do
> something like:
>
> ./myapp | unixapp
>
> ... where unixapp could be grep, less, whatever.
>
> I'm not quite sure how to go about this. I've considered creating a
> named pipe and using QFile to write to the named pipe. Is that the
> best way to go? Any suggestions before I embark on this would be very
> useful.
>
> TIA, Chris.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list