Hi everybody !

I have a strange problem this morning. I'm tryng to use a QTimer object in a class but it does not work.

I have a class which has a QTimer objet as a member. this class has also a slot to process each timer timeout.

I call a function to start the timer and check the return value of the function ... every thing is ok because the returned value is different from zero ... cool. I also check that there is no problem with the SIGNAL SLOT conection ... here again no problem. In fact there is a problem because the SLOT to process timer timeout is never called, why ?

My header file class is :
Qt Code:
  1. #include <qobject.h>
  2. #include "HmiStateA.h"
  3. #include "HmiState.h"
  4. #include "Hmi.h"
  5. #include <qtimer.h>
  6.  
  7. class CHmiStateB : public QObject, public CAvreHmiStateA
  8. {
  9. Q_OBJECT
  10.  
  11. public:
  12. static CHmiState* GetInstance();
  13. virtual ~CHmiStateB();
  14.  
  15. protected:
  16. CHmiStateB();
  17. static CHmiStateB* m_Instance;
  18.  
  19. public:
  20. virtual void ShowHmi(CHmi*);
  21. virtual void HideHmi(CHmi*);
  22. virtual void ResetHmi(CHmi*);
  23. virtual void ValidateHmiItem(CHmi*);
  24. virtual void CancelHmiItem(CHmi*);
  25.  
  26. protected slots:
  27. void ProcessTimerTimeout();
  28. protected:
  29. QTimer* pTimer;
  30. };
  31.  
  32. #endif
To copy to clipboard, switch view to plain text mode 

My implementation file class is :
Qt Code:
  1. #include "HmiStateB.h"
  2. #include "HmiStateA.h"
  3. #include <qapplication.h>
  4.  
  5. CHmiStateB* CHmiStateB::m_Instance = 0;
  6.  
  7. CHmiStateB::CHmiStateB():
  8. CHmiStateA(),
  9. pTimer(0)
  10. {
  11. if( !pTimer )
  12. {
  13. pTimer = new QTimer;
  14. Q_ASSERT( pTimer );
  15. connect(pTimer, SIGNAL(timeout()), this, SLOT(ProcessTimerTimeout()));
  16. }
  17. }
  18.  
  19. CHmiStateB::~CHmiStateB()
  20. {
  21. if( pTimer )
  22. {
  23. if( pTimer->isActive() )
  24. pTimer->stop();
  25. delete pTimer;
  26. pTimer = 0;
  27. }
  28.  
  29. }
  30.  
  31. CHmiState* CHmiStateB::GetInstance()
  32. {
  33. if( !m_Instance )
  34. m_Instance = new CHmiStateB;
  35.  
  36. return m_Instance;
  37. }
  38.  
  39. void CHmiStateB::ShowHmi(CHmi* hmi)
  40. {
  41. if( !pTimer->start(4000, TRUE) )
  42. qDebug("Failed to start timer");
  43. }
  44.  
  45. void CHmiStateB::HideHmi(CHmi* hmi)
  46. {
  47. if( pTimer->isActive() )
  48. pTimer->stop();
  49. }
  50.  
  51. void CHmiStateB::ResetHmi(CHmi* hmi)
  52. {
  53. }
  54.  
  55.  
  56. void CHmiStateB::ValidateHmiItem(CHmi* hmi)
  57. {
  58. }
  59.  
  60. void CHmiStateB::CancelHmiItem(CHmi* hmi)
  61. {
  62. }
  63.  
  64. void CHmiStateB::ProcessTimerTimeout()
  65. {
  66. qDebug("Timer Timeout");
  67. }
To copy to clipboard, switch view to plain text mode 

So if someone could tell what is wrong ?

Thanks in advance