PDA

View Full Version : QIODevice::open: File access not specified



Clausen
19th April 2015, 14:08
Hi.

I am trying to open a file with the following code:



QFile* file = new QFile(filename);
QDataStream* stream;

if (file->open(QIODevice::ReadOnly))
{
stream = new QDataStream(file);
}
else
{
PRINT("Error opening file");
return;
}



And the program outputs:
QIODevice::open: File access not specified . I would assume that the file access is ReadOnly. What am I doing wrong.
I am using Qt 5.2.1 and Qt Creator 3.0.1.

wysota
19th April 2015, 18:12
Which line prints this warning?

Clausen
19th April 2015, 19:58
That is a very good point.
It seems that it was a brainfart on my part.

The message is from somewhere else in the code where I use



file.open(QIODevice::Text);


if I change this to



file.open(QIODevice::Text|QIODevice::Append);


Then the warning disappears.

So I guess all I needed was the very good question.
Thank you for your help. :-)