Q:

How to read an XML file from the disk using Qt?

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 ?

A:

The error message is telling you that there is no constructor for the class QXmlStreamReader with the signature you are trying to invoke, i.e. the one that would accept QFile parameter alone (either by value or by reference). Reading documentation is quite helpful. Relevant extract:
QXmlStreamReader ()
QXmlStreamReader ( QIODevice * device )
QXmlStreamReader ( const QByteArray & data )
QXmlStreamReader ( const QString & data )
QXmlStreamReader ( const char * data )

Now, if you know that QFile actually inherits QIODevice (what you can find out in the documentation too), then you can immediately understand that the invocation should be changed as follows:
QXmlStreamReader xmlData(&myFile);

Furthermore, it seems like you don't know how to utilize QXmlStreamReader at 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.

