Hello all,

this is my first post in this forum, so please forgive me if there is something strange or against your rules.
(You might also recognize that I am not a native speaker).

I'm trying to learn Qt and practiced some tutorials. My first target is to build a serial-bus communication. For that I studied the Classes 'QextSerialPort' and 'qserialdevice' and decided finaly to try my luck with the 'QextSerialPort' in the 'one-class'-configuration. Finaly I want to communicate this program with my microcontrollers. (in the first step similarly like a terminal).

In order to do this, I wanted to use a seperate thread to listen if there are any kind of data comming in. I had to leran, that it es useful to understand first how threads are working.
Therefore I programmed a little Widget with a second Thread. Now my problems:

When I start the thread from my widget, it starts successfully and works pretty fine. But I don't know how do quit this thread. In the Qt documentation the methods 'quit()' and 'exit(0)' are mentioned. But when I test this, the thread works on.
A second Problem is that I need to communicate with the Widget where my QextSerialPort-Class is implemented. Unfortunately a communication between Widgets and Threads is impossible (Qt Help). So what is the best way to do it? Does it make sense to do the whole Serial-Communication in the thread or is there a different and better way to work with a thread?

btw.: Qt 4.5 , linux (ubuntu 9.10), Qt Creator.

This is the code of my little test-thread:
Qt Code:
  1. void MyThread::run()
  2. {
  3. qDebug() << "In Thread";
  4. exec();
  5. }
  6.  
  7. void MyThread::testslot()
  8. {
  9. qDebug()<<"testslot opend";
  10. }
  11.  
  12. void MyThread::killslot()
  13. {
  14. qDebug()<<"Kill thread";
  15. exit(0);
  16. }
To copy to clipboard, switch view to plain text mode 

Thanks for your Help
(if there is more code necessary, please let me know)