I get one live image from camera each time I call the function "vc3d_GetImage(0,iTotalImage,true,&iRemainImg, pB)". After that I will call the function "loadImage(unsigned char *pB)" to display the image. However the image is not updated all the while. Only the last image is showed at the end. For example I call the function "vc3d_GetImage(0,iTotalImage,true,&iRemainImg, pB)" 5 times. The display is not updated 5 times. The display is only updated once (the fifth image) at the end. What has I done wrong?

Qt Code:
  1. void MainWindow::on_pBCapture_clicked()
  2. {
  3. ui->lImageCount->setText("0");
  4. int iTotalImage = ui->sBTotalImage->value();
  5.  
  6. int iImgWidth, iImgHeight;
  7. int count = 0;
  8. unsigned char *pBuffer=NULL;
  9. unsigned char *pBuffer2=NULL;
  10.  
  11. /* to get the width and height of image */
  12. int iStatus = vc3d_GetImageSizeVr(0, &iImgWidth, &iImgHeight);
  13.  
  14. if (iStatus>0)
  15. {
  16. int iRemainImg = iTotalImage;
  17. pBuffer = new unsigned char[iImgWidth*iImgHeight];
  18. pBuffer2 = new unsigned char[iImgWidth*iImgHeight];
  19. // Get one image (or more when in a loop)
  20. do
  21. {
  22. unsigned char *pB;
  23. if (iRemainImg%2)
  24. {
  25. pB=pBuffer;
  26. }
  27. else
  28. {
  29. pB=pBuffer2;
  30. }
  31. /* Get the one image when this function is called */
  32. iStatus = vc3d_GetImage(0,iTotalImage,true,&iRemainImg, pB);
  33. if (iStatus == 1)
  34. {
  35. count++;
  36. ui->lImageCount->setText(QString::number(count));
  37. loadImage(pB);
  38. }
  39. //delete [] pBuffer;
  40. }while (iRemainImg>0 && iStatus>0);
  41. }
  42. }
  43.  
  44. void MainWindow::loadImage(unsigned char *pB)
  45. {
  46. QGraphicsScene* scene = new QGraphicsScene(this);
  47. ui->graphicsView->setScene(scene);
  48. QImage image = QImage(pB, 1280, 1024, QImage::Format_Indexed8);
  49. scene->clear();
  50. QGraphicsPixmapItem* pi = scene->addPixmap(QPixmap::fromImage(image));
  51. ui->graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
  52. ui->graphicsView->update();
  53. ui->graphicsView->viewport()->update();
  54. ui->graphicsView->show();
  55. }
To copy to clipboard, switch view to plain text mode