I want to read an xml file as follow:
QFile myFile("xmlfile");
and then continue with parsing the xml starting from :
QXmlStreamReader xmlData(myFile);
.. the error I get is:
no matching function for call to 'QXmlStreamReader::QXmlStreamReader(QFile&)'
so what is the problem and how to solve it ?
question update: Based on the selected answer below, the code is now working without a syntax error .
however, I can not read my xml. when parsing the xml, I use the following to read xml elements:
QXmlStreamReader::TokenType token = xmlElements.readNext();
then this code for checking the startElements:
while(!xmlElements.atEnd() && !xmlElements.hasError()){ // the breakpoint is here
do ...
}
so, at this breakpoint, I notice in my debuger that token value is QXmlStreamReader::Invalid(1)
so, what is going on .. is my QStreamReader does not read the file as xml, or it read it but there is an error with the xml itself ?
The error message is telling you that there is no constructor for the class
QXmlStreamReaderwith the signature you are trying to invoke, i.e. the one that would acceptQFileparameter alone (either by value or by reference). Reading documentation is quite helpful. Relevant extract:Now, if you know that
QFileactually inheritsQIODevice(what you can find out in the documentation too), then you can immediately understand that the invocation should be changed as follows:Furthermore, it seems like you don't know how to utilize
QXmlStreamReaderat all, therefore what you are looking for is a tutorial. I don't feel like rewriting great Qt tutorials here. So to intercept all your further questions, I'd refer you to the official tutorial.