QVariant returns invalid meanwhile the value is valid
<p>I have a small function like this</p>
<pre><code>bool QcgDatabase::onceindb(const QString&amp; userId)
{
    mDb-&gt;prepareSqlQuery(&quot;SELECT count(*) FROM mytable WHERE userid=:userId;&quot;, &quot;database&quot;);
    mDb-&gt;prepareBindValue(&quot;:userId&quot;, userId);
    mDb-&gt;sqlExec();

    bool d = mDb-&gt;sqlQuery().isActive();
    QVariant c = mDb-&gt;sqlQuery().value(QString(&quot;count(*)&quot;));
    int e = c.toInt();

    if (e == 1) {
        return true;
    }
    else {
        return false;
    }
}
</code></pre>
<p>When I do this command in SQL, the result looks like this</p>
<p><a href="https://i.stack.imgur.com/kQ2Ui.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kQ2Ui.png" alt="sql" /></a></p>
<p>I just want to take value <code>2</code> for comparison below, but in the code when I debug, <code>QVariant c</code> always return invalid, therefore <code>e is always = 0</code>. I thought my SQL command is not active, but when I debug, <code>bool d</code>always return true. Do you guys know why? how can I receive <code>2</code> as expected ?</p>