PDA

View Full Version : How to pipe QMessages into my ui.TextEdit?



DigiDrag
2nd September 2008, 03:32
Hi

I have a plainTextEdit in my Application, which I use to show log messages.
It works for my class functions via pipe->slot.

But how do I pipe the QMessages into that TextEdit?
qInstallMsgHandler does not allow me to use functions of my QMainWindow class...

thanks

wysota
2nd September 2008, 08:51
Make your QMainWindow a singleton or a global object. Then you'll be able to use its methods in the message handler.

DigiDrag
2nd September 2008, 12:54
Thanks, I will try that.

DigiDrag
2nd September 2008, 21:50
Hmm, it only seems to work if I declare my log function as static.
But then I cannot use ui.xxxxxx because it is not I cannot decalare ui as static.

DigiDrag
2nd September 2008, 22:19
OK, It seems I got a solution. I save the point to the TextEdit in a global pointer.



QPlainTextEdit * MyplainTextEdit=NULL;

int main(int argc, char *argv[])
{

Server main_window();
MyplainTextEdit=main_window.ui.PlainTextEdit
.....