C++ Qt - Setting QTableWidget items values
<p>I've been working on a Matrix Calculator in Qt and encountered following problem. I do this:</p>

<pre><code>void ShowMatrix::updateTable()
{
    int w = 323 - 305;
    int h = 300 - 227 + 15;

    for(int i = 0; i &lt; matrix-&gt;getRows(); i++)
    {
        ui-&gt;tableWidget-&gt;insertRow(i);
        h += 35;
    }
    for(int j = 0; j &lt; matrix-&gt;getColumns(); j++)
    {
        ui-&gt;tableWidget-&gt;insertColumn(j);
        w += 50;
    }

    this-&gt;resize(w, h);
    this-&gt;setMinimumSize(w, h);

    ui-&gt;retranslateUi(this);


    this-&gt;setWindowTitle(matrix-&gt;getName());
    emit updatingDone();

}
</code></pre>

<p>And after that, when updatingDone(); signal is emitted, this slot is launched:</p>

<pre><code>void ShowMatrix::setValues()
{
    QString str;
    for(int i = 0; i &lt; matrix-&gt;getRows(); i++)
        for(int j = 0; j &lt; matrix-&gt;getColumns(); j++)
        {
            ui-&gt;tableWidget-&gt;item(i, j)-&gt;setText("1");
        }
    ui-&gt;retranslateUi(this);
}
</code></pre>

<p>I just want to set all the cells values to ones. I can not do anything with items, everything I am trying to do with them like setting flags, values etc. crashes my application. if I don't emit <code>updatingDone()</code> signal, everything works fine.</p>