I have a class which is absfilehandler which has a QFILE pointer like this..
QString absfilename;
QFile * absfilepointer;
I have a opening method.
bool AbsFileHandler::OpenAbsFile()
{
QFile readfile(absfilename);
absfilepointer = (&readfile);
if (!(*absfilepointer).exists())
{
qDebug() << "The file" << (*absfilepointer).fileName() << "does not exist.";
return false;
}
else if (!(*absfilepointer).open((QIODevice::ReadOnly) | (QIODevice::Text)))
{
qDebug() << "Could not open" << (*absfilepointer).fileName() << "for reading.";
return false;
}
else
{
qDebug() << "File ready to read";
return true;
}
}
I call the method in the another class with a object of the same class like this myAbsFileHandler.OpenAbsFile()
if it returns true then we execute this
QTextStream readabsstream((myAbsFileHandler.absfilepointer));
But this statement gives critical exception and comes out of execution. Any idea why this is happening? Thanks.