Hello everyone

I've encountered a problem while trying to implement a polling function to fetch data from a serial port.
Qt Version is 4.3.4 and I'm using QDevelop as IDE. When I hit compile, I get a debug and a release version.
At first, I tried to set up a timer and connect its signal to the polling-method. This did work, but only in the release version. It doesn't work in the debug version nor in a static version. This seems to indicate that I created some kind of half-working solution which I just hate.
So I started reading and searching for this problem on the internet and found that setting up a timer only works when it is inside a eventloop. Since my polling class is connected to the mainWindow-class via pointer, I figured this could be the problem (Is it?).
Therefore I created a QThread-inheritance(TimerThread) to contain the polling timer. This worked eventually, but still only in the release-version of my project.
Hmpf. There still seems to be something about these signals/slots I just don't get.

My goal is having a class that handles one serial port via qextserialport and fetches data from it on a fixed timetick completely on its own. Occasionally, it gets called and returns a chunk of data. And it should be able to be included everywhere by setting up a pointer with the type of this class and construct an object on it.

This is my implementation of the thread-class whick inherits QThread:
Qt Code:
  1. #include "TimerThread.h"
  2. //******************************************************************************
  3. TimerThread::TimerThread(SerialPort *port)
  4. {
  5. this->port=port;
  6. }
  7. //******************************************************************************
  8. void TimerThread::run()
  9. {
  10. timer=new QTimer(this);
  11. timer->start(30);
  12. connect(timer, SIGNAL(timeout()), port, SLOT(fetchData()));
  13. exec();
  14. }
  15. //******************************************************************************
To copy to clipboard, switch view to plain text mode 

So, the object of TimerThread knows the object it has been created by and uses this knowledge to connect the timer-signal to the method of its creator that collects data from the serial port.

This class-object gets created like that:

Qt Code:
  1. timerPort = new TimerThread(this);
To copy to clipboard, switch view to plain text mode 

Would really appreciate any help because I totally ran out of ideas.