title: How to set the encoding of a XML file in Qt?
body: <p>I write an XML file in Qt:</p>
  
  <pre><code>QString fname = "L.xml";
  QFile file(fname);
  if (file.open(QIODevice::WriteOnly)) {
  
      QTextStream streamFileOut(&amp;file);
      streamFileOut.setCodec("Windows-1251");
  
      QString string;
  
      QXmlStreamWriter xmlWriter(&amp;string);
      xmlWriter.setAutoFormatting(true);
      xmlWriter.writeStartDocument();
          xmlWriter.writeStartElement("LIST");
  
              xmlWriter.writeStartElement("V");
              xmlWriter.writeCharacters("Привет");
              xmlWriter.writeEndElement();
  
              xmlWriter.writeStartElement("S");
              xmlWriter.writeCharacters("Привет");
              xmlWriter.writeEndElement();
  
  
          xmlWriter.writeEndElement();
      xmlWriter.writeEndDocument();
  
      streamFileOut &lt;&lt; string;
      streamFileOut.flush();
      file.close();
  }
  </code></pre>
  
  <p>I get the following XML:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;LIST&gt;
      &lt;V&gt;Привет&lt;/V&gt;
      &lt;S&gt;Привет&lt;/S&gt;
  &lt;/LIST&gt;
  </code></pre>
  
  <p>I need to get the XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1251" ?&gt;
  &lt;LIST&gt;
      &lt;V&gt;Привет&lt;/V&gt;
      &lt;S&gt;Привет&lt;/S&gt;
  &lt;/LIST&gt;
  </code></pre>
  
  <p>In my XML there is no <strong>encoding = "windows-1251"</strong>.
  How to fix this?</p>