title: qt binary file writing and reading
body: <pre><code>void write(QString filename) {
    QChar ch('b');
    QFile mfile(filename);
    if (!mfile.open(QFile::WriteOnly) {
      qDebug() &lt;&lt; "Could not open file for writing";
      return;
    }
    QDataStream out(&amp;mfile);
    out.setVersion(QDataStream::Qt_4_8);
    out &lt;&lt; ch;
    mfile.close();
  }
  </code></pre>
  
  <p>open binary file and writing 'b'(binary)</p>
  
  <pre><code>void read(QString filename) {
    QFile mfile(filename);
    if (!mfile.open(QFile::ReadOnly)) {
      qDebug() &lt;&lt; "Could not open file for reading";
      return;
    }
    QDataStream in(&amp;mfile);
    in.setVersion(QDataStream::Qt_4_8);
    QChar mT;
    in &gt;&gt; mT;
    qDebug() &lt;&lt; mT;
    mfile.close();
  }
  </code></pre>
  
  <p>read but not mT='b'.if ch and mT variables are int always mT=4 why?How can i writing ch(binary file) and read from binary file</p>