QFile Problem
-
very strange... in any case you can replace
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return;
with
if (!file.open(QIODevice::WriteOnly)) return; file.setTextModeEnabled(true);
-
Yes thats it with include<QIODevice> it works thanks so much :) and you need to include #include <qtextstream.h> for the stream too.
-
Yes thats it with include<QIODevice> it works thanks so much :) and you need to include #include <qtextstream.h> for the stream too.
@LainOnTheWired said in QFile Problem:
Yes thats it with include<QIODevice> it works thanks so much :) and you need to include #include <qtextstream.h> for the stream too.
That's very odd. The QFile header should already contain
#include <QIODevice>
...Has the QFile header been modified?
-
@VRonin
I'd be worried if I got his error message! I don't do C++/includes, but does he need to also#include <QIODevice>
for the flag definitions? -
@JonB said in QFile Problem:
I'd be worried if I got his error message!
I wouldn't. It just cannot find the
operator|()
that is defined as part of specialisingQFlags
. Not a big deal@VRonin
That's precisely what I meant! Perhaps "worried" was too strong a word :) The error message suggested to me that theQFlags
were not working correctly with the|
operator, hence my guess about not having the correct#include
. I intended to suggest that the OP should pursue why this appeared to be the case. -
It is the fault of KDevelop, if i have only the QFile include it puts this error message but if i compile the program it works correctly. The error message is wrong. Very strange and no i have not modified the header file.
-
It is the fault of KDevelop, if i have only the QFile include it puts this error message but if i compile the program it works correctly. The error message is wrong. Very strange and no i have not modified the header file.
The error message is wrong.
Up to you, but the compiler error/warning message cannot be "wrong". If it warns it means what it says in terms of not having the definition, compilers don't invent error messages. It may work at runtime if it's only a warning and the semantics actually allow an
int operator|()
to work in this case, which it probably does.Likely perhaps: if you have other
#include
s (e.g. from "KDevelop") prior (or possibly post) to your#include <QFile>
that might affect definitions/behaviour and cause your issue.... -
The error message is wrong.
Up to you, but the compiler error/warning message cannot be "wrong". If it warns it means what it says in terms of not having the definition, compilers don't invent error messages. It may work at runtime if it's only a warning and the semantics actually allow an
int operator|()
to work in this case, which it probably does.Likely perhaps: if you have other
#include
s (e.g. from "KDevelop") prior (or possibly post) to your#include <QFile>
that might affect definitions/behaviour and cause your issue....@JonB I think the error is not coming from the compiler but from the Clang Code Model which is known for producing many false positives.
@LainOnTheWired You can try to disable Clang Code Model -
@JonB I think the error is not coming from the compiler but from the Clang Code Model which is known for producing many false positives.
@LainOnTheWired You can try to disable Clang Code Model -
@jsulm
Ohhh, I don't know anything about CLang or that the OP is using that, apologies then if my comment was misleading.