Re: QFile and Creating Files
Hey, is this compiling at all?
You got it all wrong and you are right with some things :).
You can do without QTextStream
QFile inherits QIODevice which has lower level methods for reading/writing files.
Your logic in writing this program is not correct.
Code:
void DialogIml::DialogImpl(...)
{
mFile
= new QFile(somePath
);
//sice you require constatnt access to the file, it should be a member in your class. mFile
->open
(QIODevice::WriteOnly);
//this should create the file if it does not exist //be careful because that could return false - if you lack permissions,etc
}
void DialogImpl::~DialogImpl()
{
if(mFile)
{
mFile->close();
delete mFile;
}
}
void DialogImpl::DoSomething()
{
if(mFile->isOpen())
{
mFile->write(linedt.ascii());//Writes a QByteArray to the file.
}
}
Should be more or less like this.
Regards
Re: QFile and Creating Files
Ahh thats exactly what I was looking for. I knew the answer was probably fairly simple, but I could not seem to grasp how I would obtain constant access to the file. Of course now it seems really simple and I feel like a tool... :D hehe.
Thank you for the quick response though as I am thoroughly enjoying QT.