Why QMimeData is returning invalid QStringList at each call of member func formats()?
<p>I was trying to use a for each [Modern c++ style] but the code is crashed each time!
It was something like :</p>

<pre><code>for(auto &amp;k:mimeData-&gt;formats())
{ ... }
</code></pre>

<p>And later out of my surprises I found that the QStringList returned by formats is either invalid or completely separate object though the internal data is ought to be same!
So I tried to figure out in more simple example :</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;list&gt;

#include &lt;QCoreApplication&gt;
#include &lt;QMimeData&gt;

using namespace std;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    cout&lt;&lt;boolalpha;

    list&lt;string&gt; ls;
    cout&lt;&lt;(ls.begin() != ls.end())&lt;&lt;"\n";

    QStringList qsl;
    cout&lt;&lt;(qsl.begin() != qsl.end())&lt;&lt;"\n";

    QMimeData qme;

    cout&lt;&lt;(qme.formats().begin() != qme.formats().end())&lt;&lt;"\n";
    cout&lt;&lt;"OMG! is it empty? -&gt;  "&lt;&lt;qme.formats().empty()&lt;&lt;"\n";

    return a.exec();
}
</code></pre>

<p>The output is something like :</p>

<pre><code>false
false
true
OMG! is it empty? -&gt;  true
</code></pre>

<p>Until or unless I take an rvalue reference I cant decide what is happening internally! </p>

<p>I really  need a solution to use it with range based for loops, not Qt's foreach!</p>

<p>P.S. I dont want to copy it to avoid O(n). </p>