ok, I have changed my code and it is like this now;

QTMainForm::QTMainForm(QWidget* parent)
{

btn.setText("Start");
connect(&btn, SIGNAL(clicked()), this, SLOT(OnBtnstrt()));
progress.setValue(0);

progress.setRange(0, 1000000);

vb.addWidget(&progress);
vb.addWidget(&btn);
setLayout(&vb);
}

void QTMainForm::OnBtnstrt()
{
double i=0;
while(i<=1000000)
{
i++;
qApp->processEvents();

progress.setValue(i);
}
}

still the same problem occurs. As I was observing if I put the value of "i" 1000000 the process stop when I close the window but if I put the value of "i" >1000000 then the problem occurs. any suggestions?