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,
Hemanth -
Hi and welcome to devnet,
Take a look at this Wiki article. It shows a possible implementation.
Hope it helps.
-
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
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