Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Display compiler output to a textbrowser in GUI

Display compiler output to a textbrowser in GUI

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    ghkraju
    wrote on last edited by
    #1

    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,
    Hemanth

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

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

      Hope it helps.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • G Offline
        G Offline
        ghkraju
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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 :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • G Offline
            G Offline
            ghkraju
            wrote on last edited by
            #5

            I have used the following way to solve:

            // Keep Handler before the "QApplication" function in main.cpp
            qInstallMessageHandler(myMessageOutput);
            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)
            {
            if(w){
            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;
             w->updateLog(totmsg);
            

            }


            // tBrowser is my textarea in a widget in the main window
            void MainWindow::updateLog(const QString &msg){
            ui->widget->tBrowser->append(msg);
            }

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

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved