<?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[Signal returnPressed() doesn&#x27;t work in setModelData]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I'm trying to use signal returnPressed() in setModelData:</p>
<pre><code>void myDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &amp;index) const
{
    QLineEdit *edit = qobject_cast&lt;QLineEdit*&gt;(editor);

    if(edit)
        {
            model-&gt;setData (index,edit-&gt;text ());
            QVariant f(index.data(Qt::DisplayRole));
            QString modified;
            modified = f.toString ();
            qDebug() &lt;&lt; "Modified: " &lt;&lt; modified;
            connect(edit,SIGNAL(returnPressed()), this,SLOT(saveChangedItem()));

            return;
        }
}
</code></pre>
<p dir="auto">Everything works fine but when the connect processed nothing happens (it does not go to saveChangedItem(). Please point me to the right direction to make this work. Thank you.</p>
]]></description><link>https://forum.qt.io/topic/72858/signal-returnpressed-doesn-t-work-in-setmodeldata</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 12:06:51 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/72858.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 31 Oct 2016 03:08:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Signal returnPressed() doesn&#x27;t work in setModelData on Mon, 31 Oct 2016 07:50:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Provide the debug statement and check the return value, to ensure the signal  is emitted  or not,<br />
and connect() statements establish connection between two objects, and will not call slot until the signal of one object is emitted.</p>
<pre><code>bool   value =  &lt;&lt; connect(edit,SIGNAL(returnPressed()), this,SLOT(saveChangedItem()));

qDebug () &lt;&lt; value &lt;&lt; endl;
</code></pre>
<p dir="auto">Sample Program : to ensure signal is emitted or not.</p>
<pre><code>m_edit = new QLineEdit;
m_label = new QLabel

value =  connect(m_edit,SIGNAL(returnPressed()),this,SLOT(getData()),Qt::UniqueConnection);
</code></pre>
<p dir="auto">void LineEDitSignal::getData()<br />
{<br />
qDebug () &lt;&lt; value;</p>
<pre><code>    m_label-&gt;setText(m_edit-&gt;text());
    qDebug () &lt;&lt; "lineedit value :" &lt;&lt; m_edit-&gt;text() &lt;&lt; endl;
</code></pre>
<p dir="auto">}</p>
<p dir="auto">Thanks,</p>
]]></description><link>https://forum.qt.io/post/357179</link><guid isPermaLink="true">https://forum.qt.io/post/357179</guid><dc:creator><![CDATA[Pradeep Kumar]]></dc:creator><pubDate>Mon, 31 Oct 2016 07:50:57 GMT</pubDate></item><item><title><![CDATA[Reply to Signal returnPressed() doesn&#x27;t work in setModelData on Mon, 31 Oct 2016 05:30:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gabor53">@<bdi>gabor53</bdi></a> Are you aware that connect() does not call the slot? It just connect the signal to the slot. The slot is called when the signal appears. That means</p>
<pre><code>connect(edit,SIGNAL(returnPressed()), this,SLOT(saveChangedItem()));
</code></pre>
<p dir="auto">will not call saveChangedItem().<br />
saveChangedItem() will be called as soon as returnPressed() is emitted in edit.<br />
So, is the signal emitted?<br />
To be sure connect() succeeded you should print out its return value:</p>
<pre><code>qDebug() &lt;&lt; connect(edit,SIGNAL(returnPressed()), this,SLOT(saveChangedItem()));
</code></pre>
]]></description><link>https://forum.qt.io/post/357170</link><guid isPermaLink="true">https://forum.qt.io/post/357170</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 31 Oct 2016 05:30:32 GMT</pubDate></item></channel></rss>