Qt World Summit: Register Today!

Display compiler output to a textbrowser in GUI

  • Hi,

    I wanted to display my console/compiler output in a textBrowser in GUI. I have used qInstallMessageHandler to catch the messages and can able to print to a text file successfully but i am unable to print it in the textBrowser.

    I tried working with signals and slots but i am unable to get it. Any ideas/help would be much appreciated.

    Thanks in Advance,

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Take a look at this Wiki article. It shows a possible implementation.

    Hope it helps.

  • Thank you.... SGaist Finally I found a way to display the compiler output back to my GUI. In the next post I will try to put the code for future reference to others.

  • Lifetime Qt Champion

    Great !

    Then please mark the thread as solved using the "Topic Tools" button so that other forum members may know a solution has been found :)

  • I have used the following way to solve:

    // Keep Handler before the "QApplication" function in main.cpp
    QApplication a(argc, argv);

    // w is my MainWindow here
    // Message Handler outside main method is as follows
    void myMessageOutput(QtMsgType type, const QMessageLogContext & context, const QString & msg)
    QDateTime dTime(QDateTime::currentDateTime());
    QString timeStr(dTime.toString("dd-MM-yyyy HH:mm:ss:zzz"));
    QString contextString(QString("(%1, %2)").arg(context.file).arg(context.line));

     QString totmsg;
     totmsg += timeStr + " " + contextString + ": " + msg;


    // tBrowser is my textarea in a widget in the main window
    void MainWindow::updateLog(const QString &msg){

    I hope this helps. If in case of any issues please comment..... I can help as much as I can

Log in to reply