Results 1 to 5 of 5

Thread: How to pipe QMessages into my ui.TextEdit?

  1. #1
    Join Date
    Sep 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to pipe QMessages into my ui.TextEdit?

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to pipe QMessages into my ui.TextEdit?

    Make your QMainWindow a singleton or a global object. Then you'll be able to use its methods in the message handler.

  3. #3
    Join Date
    Sep 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to pipe QMessages into my ui.TextEdit?

    Thanks, I will try that.

  4. #4
    Join Date
    Sep 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to pipe QMessages into my ui.TextEdit?

    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.

  5. #5
    Join Date
    Sep 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to pipe QMessages into my ui.TextEdit?

    OK, It seems I got a solution. I save the point to the TextEdit in a global pointer.


    Qt Code:
    1. QPlainTextEdit * MyplainTextEdit=NULL;
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5.  
    6. Server main_window();
    7. MyplainTextEdit=main_window.ui.PlainTextEdit
    8. .....
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 13th September 2008 at 15:57. Reason: missing [code] tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.