<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Deleting rows from QTableWidget]]></title><description><![CDATA[<p dir="auto">Hello guys, can someone help me?<br />
I am trying to delete row from a QTableWidget.<br />
So, i have:</p>
<pre><code>food_table = new QTableWidget(1, 2);
</code></pre>
<p dir="auto">then, it connects to a slot</p>
<pre><code>connect(food_table, SIGNAL(cellChanged(int,int)), this, SLOT(checkTheCells(int,int)));
</code></pre>
<p dir="auto">slot code:</p>
<pre><code>void InsertNewEatingDialog::checkTheCells(int changed_row, int changed_column)
{
    int total_rows{food_table-&gt;rowCount()};
    if(rowIsEmpty(changed_row) &amp;&amp; total_rows &gt; 1) food_table-&gt;removeRow(changed_row);
    if(tableIsFull()) food_table-&gt;insertRow(total_rows);
}
</code></pre>
<p dir="auto">rowIsEmpty() and tableIsFull() are just bool member functions.<br />
And it all works, but when the code running, when the row was deleted, i receive a message in qt developer's terminal, which says:</p>
<pre><code>QAbstractItemView::commitData called with an editor that does not belong to this view
</code></pre>
<p dir="auto">and then the program continues to run normally until the next row deleting. Then that message again.<br />
I noticed that if I replace 1 with 2 in the line</p>
<pre><code>if(rowIsEmpty(changed_row) &amp;&amp; total_rows &gt; 1) food_table-&gt;removeRow(changed_row);
</code></pre>
<p dir="auto">it works without any messages.<br />
Can someone explain me the cause of the error and a possible solution?</p>
]]></description><link>https://forum.qt.io/topic/165247/deleting-rows-from-qtablewidget</link><generator>RSS for Node</generator><lastBuildDate>Mon, 09 Nov 2026 11:37:12 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/165247.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 06 Nov 2026 19:27:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Deleting rows from QTableWidget on Sat, 07 Nov 2026 09:08:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a><br />
Ok, thank you, i'll read it</p>
]]></description><link>https://forum.qt.io/post/840816</link><guid isPermaLink="true">https://forum.qt.io/post/840816</guid><dc:creator><![CDATA[Jabik]]></dc:creator><pubDate>Sat, 07 Nov 2026 09:08:32 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting rows from QTableWidget on Sat, 07 Nov 2026 09:03:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jabik">@<bdi>Jabik</bdi></a> said in <a href="/post/840813">Deleting rows from QTableWidget</a>:</p>
<blockquote>
<p dir="auto">But to understand, what is "the editor"? Is it an object inside QT library, or is it an external process in OS?</p>
</blockquote>
<p dir="auto">When you edit a cell, an editor is created so you can enter the new value.<br />
See <a href="https://doc.qt.io/qt-6/model-view-programming.html#delegate-classes" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/model-view-programming.html#delegate-classes</a></p>
]]></description><link>https://forum.qt.io/post/840815</link><guid isPermaLink="true">https://forum.qt.io/post/840815</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Sat, 07 Nov 2026 09:03:22 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting rows from QTableWidget on Sat, 07 Nov 2026 08:51:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a><br />
Yeah, that works perfectly.<br />
But to understand, what is "the editor"?  Is it an object inside QT library, or is it an external process in OS?<br />
How can I interact with it?<br />
Or just, where to read about it?</p>
]]></description><link>https://forum.qt.io/post/840813</link><guid isPermaLink="true">https://forum.qt.io/post/840813</guid><dc:creator><![CDATA[Jabik]]></dc:creator><pubDate>Sat, 07 Nov 2026 08:51:28 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting rows from QTableWidget on Fri, 06 Nov 2026 21:21:30 GMT]]></title><description><![CDATA[<p dir="auto">The problem is that the editor is not yet closed when cellChanged()/dataChanged() is emitted and you're killing the row where the editor lives in. Use a Qt::QueuedConnection:</p>
<pre><code>int main(int argc, char* argv[])
{
    QApplication a(argc, argv);
    QTableWidget tw(10, 10);
    QObject::connect(&amp;tw, &amp;QTableWidget::cellChanged, &amp;tw, [&amp;](int row, int) {
        tw.removeRow(row);
        }, Qt::QueuedConnection);
    tw.show();
    return a.exec();
}
</code></pre>
]]></description><link>https://forum.qt.io/post/840810</link><guid isPermaLink="true">https://forum.qt.io/post/840810</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 06 Nov 2026 21:21:30 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting rows from QTableWidget on Fri, 06 Nov 2026 21:10:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> said in <a href="/post/840807">Deleting rows from QTableWidget</a>:</p>
<blockquote>
<p dir="auto">welcome to devnet,</p>
</blockquote>
<p dir="auto">thx</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> said in <a href="/post/840807">Deleting rows from QTableWidget</a>:</p>
<blockquote>
<p dir="auto">How are you editing your cells ?</p>
</blockquote>
<p dir="auto">standard editing with left click (or dbl click) and entering the value, then "enter", or just click somewhere outside the editing cell</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> said in <a href="/post/840807">Deleting rows from QTableWidget</a>:</p>
<blockquote>
<p dir="auto">How are you deleting your cells ?<br />
i'm dbl clicking the cell, then just "delete". then "enter" or click somewhere outside the cell. I understand, that this action just makes QTableWidgetItem's text empty and nothing more.</p>
</blockquote>
<p dir="auto">but any of these actions emits signal cellChanged(int, int).<br />
this signal is connected with my own slot checkTheCells(int, int);</p>
<p dir="auto">then, inside the signal i'm checking if row is empty. Empty means, that either:</p>
<ul>
<li>every cell item is empty</li>
</ul>
<pre><code>QTableWidgetItem* item; 
if(!item){...}
</code></pre>
<p dir="auto">-or</p>
<pre><code>item-&gt;text().size() == 0
</code></pre>
<p dir="auto">if all cells in a row are empty, then i'm removing the whole row, because i don't need it</p>
<pre><code>if(rowIsEmpty(changed_row) &amp;&amp; total_rows &gt; 1) food_table-&gt;removeRow(changed_row);
</code></pre>
<p dir="auto">that's all</p>
]]></description><link>https://forum.qt.io/post/840809</link><guid isPermaLink="true">https://forum.qt.io/post/840809</guid><dc:creator><![CDATA[Jabik]]></dc:creator><pubDate>Fri, 06 Nov 2026 21:10:31 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting rows from QTableWidget on Fri, 06 Nov 2026 19:31:15 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">Any chances you have an editor opened in the row you are trying to delete ?<br />
How are you editing your cells ?<br />
How are you deleting your cells ?</p>
]]></description><link>https://forum.qt.io/post/840807</link><guid isPermaLink="true">https://forum.qt.io/post/840807</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 06 Nov 2026 19:31:15 GMT</pubDate></item></channel></rss>