hi All,

i want to change my msleep seconds by QSlider.According to the value change in slider ,the seconds should be changed.

Qt Code:
  1. class MyThread :public QThread
  2.  
  3. {
  4.  
  5. Q_OBJECT
  6.  
  7. private:
  8.  
  9. bool m_bToSuspend;
  10.  
  11. QWaitCondition m_waitCondt;
  12.  
  13. public :
  14.  
  15. QMutex mutex;
  16.  
  17. QWaitCondition wcCondition;
  18.  
  19. int count,iSeconds;
  20.  
  21. MyThread()
  22.  
  23. {
  24.  
  25. count=0;
  26.  
  27. m_bToSuspend=false;
  28.  
  29.  
  30. iSeconds=1000;
  31.  
  32. }
  33.  
  34. void run()
  35.  
  36. {
  37.  
  38. QMutex waitMutex;
  39.  
  40. //qDebug()<<"count : "<<count;
  41.  
  42. for (int i=0;i<count;)
  43.  
  44. {
  45.  
  46. msleep(iSeconds);
  47.  
  48. qDebug()<<iSeconds;
  49.  
  50. emit changeValue(i);
  51.  
  52. // pause the simulator
  53.  
  54. if (m_bToSuspend)
  55.  
  56. {
  57.  
  58. waitMutex.lock();
  59.  
  60. m_waitCondt.wait(&waitMutex);
  61.  
  62. waitMutex.unlock();
  63.  
  64. }
  65.  
  66. i+=3;
  67.  
  68. }
  69.  
  70. }
  71.  
  72. signals:
  73.  
  74. void changeValue(int i);
  75.  
  76. public slots:
  77.  
  78. void getCount (int pCount)
  79.  
  80. {
  81.  
  82. count=pCount;
  83.  
  84. }
  85.  
  86. void suspend();
  87.  
  88. void startThread();
  89.  
  90. void getTimer(int pval)
  91.  
  92. {
  93.  
  94. iSeconds=pval*100;
  95.  
  96. }
  97.  
  98. };
To copy to clipboard, switch view to plain text mode 

In this getTimer() slot is used by the slider control.
connect(slider,SIGNAL(valuchanged(int)),thread,SLO T(getTimer()));
The thread is started after creating a instance of the class MyThread;