View Full Version : Simulating a console window
Doug Broadwell
18th October 2006, 21:15
Is there a way to implement a "stdout" type of widget in Qt, e.g., a textbox type window that either printf() output would go to (like a terminal) or sprintf() character buffers?
high_flyer
18th October 2006, 23:18
I think this might be helpful:
http://www.qtcentre.org/forum/f-qt-programming-2/t-redirect-printf-to-qtextedit-3901.html/?highlight=printf
jrideout
19th October 2006, 02:08
Check out qt-interest 2004-03 (http://lists.trolltech.com/qt-interest/2004-03/msg00407.html). The last two messages have two different interesting solutions.
RedDev
18th February 2011, 15:30
Hi,
I ran into a similar problem, but haven't found a working solution yet.
Under the hood of my Qt application I'm using a special purpose library were a cannot change the code. It uses printf() to output errors and warnings.
What I want to do is catch those printf's and print them into a QPlainTextEdit.
I need a solution for Windows and Linux.
On Windows I tried this:
// Create a pipe
HANDLE hPipe = CreateNamedPipe("\\\\.\\pipe\\MyPipeNameHere", PIPE_ACCESS_OUTBOUND | WRITE_DAC,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1,
1024, 1024, 2000, NULL);
// let a SocketNotifier watch that pipe
QSocketNotifier* notifier = new QSocketNotifier((int)hPipe, QSocketNotifier::Read);
connect(notifier, SIGNAL(activated(int)), SLOT(outputReceived()));
But I don't receive anything on that slot.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.