safknw
16th September 2006, 12:33
I made a dialog which takes, which two files as argument first one is source file nad second is destination file to copy first file.
void mainForm::copy()
{
QFile src1 (le_src->text() );
QFile dest (le_dest->text() );
if(!src1.open(IO_ReadOnly) || !dest.open(IO_WriteOnly))
return;
else
qDebug("Files opened.");
int len = src1.size()/1024;
progress->setTotalSteps(len);
progress->show();
char *ch;
while(!src.atEnd())
{
//ch = src.getch();
src1.readBlock(ch, Q_ULONG(1042));
//dest.putch(ch);
dest.writeBlock (ch, Q_ULONG(1042));
progress->setProgress(progress->progress()+1);
//qApp->processEvents();
}
}
When I run this code following out put shows
Files opened.
QFile::writeBlock: File not open
Segmentation fault
I didn't understand what is wrong with this code.
void mainForm::copy()
{
QFile src1 (le_src->text() );
QFile dest (le_dest->text() );
if(!src1.open(IO_ReadOnly) || !dest.open(IO_WriteOnly))
return;
else
qDebug("Files opened.");
int len = src1.size()/1024;
progress->setTotalSteps(len);
progress->show();
char *ch;
while(!src.atEnd())
{
//ch = src.getch();
src1.readBlock(ch, Q_ULONG(1042));
//dest.putch(ch);
dest.writeBlock (ch, Q_ULONG(1042));
progress->setProgress(progress->progress()+1);
//qApp->processEvents();
}
}
When I run this code following out put shows
Files opened.
QFile::writeBlock: File not open
Segmentation fault
I didn't understand what is wrong with this code.