PDA

View Full Version : Showing Output from external QThread on Local QTextEdit object (Qt 4, SuSe Linux 10)



freak
10th May 2006, 18:37
I have a Gui app that contains a QTextEdit object. From this app I start a separate QThread. What is the best way, if possible, for the QThread to print messages to the QTextEdit on the main Gui app.

Any help is greatly appreciated.

Thanks in advanced.

wysota
10th May 2006, 18:42
Make your thread emit a signal with the text to be appended to the text edit and connect it to QTextEdit::append() slot.

jacek
10th May 2006, 18:44
Make sure you use a queued connection.

freak
10th May 2006, 18:48
Thanks for the help guys. This really gives me an idea and how to get this done. I'll post how it went.

Thanks again

freak
10th May 2006, 23:37
I was able to make this work by connecting the signal inside my thread to the textEdit box.

eg:

GUI APP:

thread = new mythread();

connect(thread, SIGNAL(mysignal(QString)), textEdit, SLOT(append(QString)), Qt::QueuedConnection);

THREAD:

mythread::send(QString str)
{
emit mysignal(str);
}

thanks for the help.