Hi no problem,

this is my thread-class:
Qt Code:
  1. #ifndef THREADS_H
  2. #define THREADS_H
  3.  
  4. #include <QThread>
  5.  
  6.  
  7. class serial; //forward decl.
  8. class threads : public QThread
  9. {
  10. Q_OBJECT
  11.  
  12. public:
  13. threads(QObject *parent,bool); //here i push the this-pointer of my serial class, so my Threads can call serial-class methods
  14. ~threads();
  15. threads(threads &);
  16. void stopAll(); // to stop my threads static var is set
  17. protected:
  18. void run();
  19.  
  20. private:
  21. bool readerFlagIsSet,writerFlagIsSet; //ctor will set what kind of thread it is
  22. static bool threadDone;
  23. serial *serialPtr; // pointer to serial class object
  24. };
  25. #endif // THREADS_H
To copy to clipboard, switch view to plain text mode 
this is my serial class:

Qt Code:
  1. #ifndef SERIAL_H
  2. #define SERIAL_H
  3.  
  4. #include <QObject>
  5. #include <QString>
  6. #include <QByteArray>
  7. #include <QList>
  8. #include <QMutex>
  9. #include "define.h"
  10. #include "storage.h"
  11. #include <windows.h>
  12. #include "threads.h" // my thread class (above)
  13. #include "Serial\Serial.h" // this is the foreign serial lib I use
  14.  
  15.  
  16. class serial : public QObject
  17. {
  18. Q_OBJECT
  19.  
  20. public:
  21. serial(QObject *parent);
  22. ~serial();
  23. serial(serial&);
  24. bool openserialport(QString);
  25. bool closeserialport();
  26. QList<QString> scanSerialPorts();
  27. void ResetEvents();
  28.  
  29. //threads fct
  30.  
  31. bool read(); //called by reader-thread in its loop.
  32. //inside the read fct it waits for com events (WaitForMultipleObjects (Win32)) and blocks until data is there
  33. bool isOpen();
  34. bool isWriteJobAvailable(); //called by writer thread, to check if there is data in outgoing queue (to write)
  35. void writeNewJob();// called by writer thread, to get data from queue and call write(QByteArray)
  36. bool write(QByteArray); //called indirectly by writer thread to write data on device
  37.  
  38.  
  39. signals:
  40. void dataIN(); //emit signal when data is read in reader-thread, to inform another thread
  41.  
  42. private:
  43. CSerial cserial; //foreign serial lib I use to access COM port
  44. threads *readerThread,*writerThread; // pointer of type Threads
  45. QByteArray *readBuf;
  46. bool fContinue;
  47. bool portIsOpen;
  48.  
  49. };
  50.  
  51. #endif // SERIAL_H
To copy to clipboard, switch view to plain text mode 
In my ctor of my serial class i create two instances, one for readerThread and one for writerThread and start the Threads.

Ctor of Serial Class:
Qt Code:
  1. reader = new threads(this,true);
  2. writer = new threads(this,false);
  3.  
  4. reader->start();
  5. writer->start();
To copy to clipboard, switch view to plain text mode 
run() of Threads:
Qt Code:
  1. void threads::run()
  2. {
  3. if(isReaderThread)
  4. while(!threadDone){ //static var which will be set to stop the threads
  5. serialPtr->read(); //serial class fct called with the pointer (got it inside from ctor)
  6. msleep(50);
  7. }
  8.  
  9. if(isWriterThread)
  10. while(!threadDone){
  11. if(serialPtr->isWriteJobAvailable()) //serial class fct called with the pointer (got it inside from ctor)
  12. serialPtr->writeNewJob();
  13. msleep(50);
  14. }
  15. }
To copy to clipboard, switch view to plain text mode 

Thanks!