Hi All

Working on Qt4.4.3, using my intel mac machine. What I am trying to do is,
I am selecting a file/folder using QFileDialog, and open that file in read write mode and writing that file with some other text, For this process I am using thread, I am selecting file in one class, and after selection i called thread , Using thread , I called some other class for writing on that selected file . For writing on the file, i want to run progressBar, till the writing completes, but its not working, i dont know why,

Qt Code:
  1. void ClassWrite::fnWriteFile(FILE *fp, int nFillWith)
  2. {
  3. unsigned long value = 0;
  4. int iProgressCounter = 0;
  5. long long llSizeRead = 0;
  6. unsigned long SizetoRead =0;
  7. long long SizeRead = 0;
  8. QFileInfo filename(m_FileName);
  9. llSizeRead = filename.size();
  10. QString strMessage = "";
  11. unsigned char *pBuffer = NULL;
  12. unsigned long dwBufferValue = 4*1024*1024;
  13. pBuffer = (unsigned char *)calloc(dwBufferValue,sizeof(unsigned char));
  14. if(pBuffer == NULL)
  15. return;
  16.  
  17. strMessage = "WritingFile " + m_FileName;
  18. emit ProgressMaximumValue(100);
  19. qApp->processEvents();
  20.  
  21. while(llSizeRead>0)
  22. {
  23. if(bStopFlag)
  24. break;
  25.  
  26.  
  27. if(llSizeRead>dwBufferValue)
  28. {
  29. SizetoRead = dwBufferValue;
  30. value = ((SizetoRead/llSizeRead)*100);
  31. if(iProgressCounter == 0 || iProgressCounter == 100)
  32. {
  33. emit SetProgressValue(strMessage,value);
  34. qApp->processEvents();
  35. memset(pBuffer,nFillWith,SizetoRead);
  36. fseek(fp, 0+SizeRead, SEEK_CUR);
  37. fwrite((void*)pBuffer,SizetoRead,1,fp);
  38. llSizeRead-=SizetoRead;
  39. SizeRead = SizetoRead;
  40. iProgressCounter = 0;
  41. }
  42. iProgressCounter++;
  43. }
  44. else
  45. {
  46. SizetoRead = llSizeRead;
  47. value = ((SizetoRead/llSizeRead)*100);
  48. if(iProgressCounter == 0 || iProgressCounter == 100)
  49. {
  50. emit SetProgressValue(strMessage,value);
  51. qApp->processEvents();
  52. memset(pBuffer,nFillWith,SizetoRead);
  53. fseek(fp, 0+SizeRead, SEEK_CUR);
  54. fwrite((void*)pBuffer,SizetoRead,1,fp);
  55. llSizeRead-=SizetoRead;
  56. SizeRead = SizetoRead;
  57. iProgressCounter = 0;
  58. }
  59. iProgressCounter++;
  60. }
  61.  
  62.  
  63. }
  64.  
  65. fflush(fp);
  66. if(pBuffer)
  67. {
  68. free(pBuffer);
  69. pBuffer = NULL;
  70. }
  71. }
To copy to clipboard, switch view to plain text mode 

Pls suggest me something