Hi everybody,

I am having one problem, i am giving you code can you find out where is problem.

header file:
Qt Code:
  1. class MainDialog : public QDialog
  2. {
  3. Q_OBJECT
  4. public:
  5. MainDialog();
  6. private:
  7. QLabel* labelText;
  8. QLabel* labelImage;
  9. QTimer *timer;
  10. QPushButton* startButton;
  11. QPushButton* quitButton;
  12. QSpacerItem* vspacer;
  13.  
  14. QStringList imagesStrList;
  15. int count;
  16. int listSize;
  17. private slots:
  18. void updateImages();
  19. void animateImage();
  20. };
To copy to clipboard, switch view to plain text mode 

src file:
Qt Code:
  1. MainDialog::MainDialog() : QDialog()
  2. {
  3. QVBoxLayout *mainLayout = new QVBoxLayout(this);
  4. QHBoxLayout *hLayout = new QHBoxLayout;
  5.  
  6. labelText = new QLabel;
  7. labelText->setText("My Dialog ... !");
  8.  
  9. labelImage = new QLabel;
  10.  
  11. vspacer = new QSpacerItem(20, 150, QSizePolicy::Expanding, QSizePolicy::Minimum);
  12.  
  13. startButton = new QPushButton("Start");
  14. quitButton = new QPushButton("Quit");
  15.  
  16. hLayout->addWidget(startButton);
  17. hLayout->addWidget(quitButton);
  18.  
  19. mainLayout->addWidget(labelText);
  20. mainLayout->addItem(vspacer);
  21. mainLayout->addLayout(hLayout);
  22.  
  23. timer = new QTimer;
  24. imagesStrList << ":/images/1.png"
  25. << ":/images/2.png"
  26. << ":/images/3.png"
  27. << ":/images/4.png"
  28. << ":/images/5.png"
  29. << ":/images/6.png";
  30.  
  31. count = 0;
  32. listSize = imagesStrList.size();
  33.  
  34. connect(timer, SIGNAL(timeout()),this, SLOT(updateImages()));
  35. connect(startButton, SIGNAL(clicked()),this, SLOT(animateImage()));
  36. connect(quitButton, SIGNAL(clicked()),this, SLOT(close()));
  37.  
  38. //timer->start(400); //[COLOR="#0000FF"] it's working[/COLOR]
  39.  
  40. resize(320,240);
  41.  
  42. }
  43.  
  44. void MainDialog::updateImages()
  45. {
  46. qDebug("update");
  47. labelImage->setPixmap(QPixmap(imagesStrList.at(count++)));
  48. labelImage->show();
  49.  
  50. if(count>=listSize){
  51. count=0;
  52. }
  53.  
  54. }
  55.  
  56. void MainDialog::animateImage()
  57. {
  58. timer->start(400); //[COLOR="#FF0000"] It's not calling timer slot, I have to srart timer in this slot[/COLOR]
  59. for(int i=0; i<10; i++){
  60. qDebug("LOOP : %d",i);
  61. sleep(1);
  62. }
  63. timer->stop();
  64. }
To copy to clipboard, switch view to plain text mode 

main file:
Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QApplication a(argc, argv);
  4.  
  5. Q_INIT_RESOURCE(resource);
  6.  
  7. MainDialog dlg;
  8. dlg.show();
  9.  
  10. return a.exec();
  11. }
To copy to clipboard, switch view to plain text mode 

i have to start my timer in different slot, but it's not calling the timer slot, if i am starting the timer in constructor, it's working fine.
can you tel me where i am doing wrong ?