PDA

View Full Version : Accessing TextEdit from a thread.



dsmcc
8th November 2008, 07:55
Hi,
I am beginner in Qt.. I have created a GUI with Qt Designer 3.3. I start a QThread when I press a button in the GUI. The thread works fine but now I want the thread to append text in a TextEdit widget on my GUI. I tried this method below to connect my signal to the slot but I get the error that : QueuedConnection' is not a member of `Qt'

void Form1::ImportFile() // On pressing Start Button
{
ImportThread *IThread = new ImportThread;
QObject::connect (IThread,SIGNAL(mysignal(QString)), textEdit1, SLOT(append(QString)), Qt::QueuedConnection);
....
}
can anyone help me?
Thanks,
dsmcc.

caduel
8th November 2008, 09:47
i) Qt::QueuedConnection was introduced with Qt4. Bad luck.
ii) accessing a QTextEdit from a different thread is not allowed
(queued signals would be ok (they are not really accessing it directly), but in your case: not available)

You have to upgrade Qt, or deliver a custom event or do real threads programming (with synchronization etc).

The easiest way is to use Qt4, if possible.