<?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[[SOLVED] Add QLabel and QLineEdit from formLayout to QHash]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I have a FormLayout, with several rows which have one Label and one QLineEdit created like this:</p>
<p dir="auto">@<br />
for(int i=0; i&lt;class.count(); i++)<br />
{<br />
lineEdit = new QLineEdit;<br />
label = new QLabel;<br />
label-&gt;setText(class-&gt;getName(i));<br />
formLayout-&gt;addRow(label, lineEdit);<br />
}<br />
@</p>
<p dir="auto">I want to get the added content on the lineEdit with its label to a QHashTable. I've already tried some things like using textEdited but there I can only get the content of the lineEdit. With other things like editingFinished I cannot even get that.</p>
<p dir="auto">I'm really stuck so any help would be appreciated!!!</p>
<p dir="auto">Thanks in advance!</p>
]]></description><link>https://forum.qt.io/topic/44088/solved-add-qlabel-and-qlineedit-from-formlayout-to-qhash</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 11:06:17 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/44088.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Jul 2014 09:04:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] Add QLabel and QLineEdit from formLayout to QHash on Fri, 25 Jul 2014 12:25:06 GMT]]></title><description><![CDATA[<p dir="auto">Hi! Thanks!!<br />
I finally managed to do it but in another way, because the problem I see with your solution (I think) is that I would only get the last label. I did it like this:</p>
<p dir="auto">@</p>
<p dir="auto">for(int i=0; i&lt;class.count(); i++)<br />
{<br />
lineEdit = new QLineEdit;<br />
lineEdit-&gt;setAccessibleName(class-&gt;get-&gt;Name(i));<br />
label = new QLabel;<br />
label-&gt;setText(class-&gt;getName(i));<br />
formLayout-&gt;addRow(label, lineEdit);</p>
<p dir="auto">connect(lineEdit, SIGNAL(textEdited(QString)),<br />
this, SLOT(addHash(QString)));<br />
}<br />
@</p>
<p dir="auto">And the slot would look like this:</p>
<p dir="auto">@<br />
void addHash(QString text)<br />
{<br />
QLineEdit <em>edit = qobject_cast&lt;QLineEdit</em>&gt;(sender());<br />
hash.insert(edit-&gt;accessibleName(), text);<br />
}<br />
@</p>
<p dir="auto">The key to it is the sender function which I didnt know it existed.</p>
<p dir="auto">Thank you!</p>
]]></description><link>https://forum.qt.io/post/237217</link><guid isPermaLink="true">https://forum.qt.io/post/237217</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 25 Jul 2014 12:25:06 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Add QLabel and QLineEdit from formLayout to QHash on Fri, 25 Jul 2014 10:28:02 GMT]]></title><description><![CDATA[<p dir="auto">Hope it is QHash data  structure. You need to work with signals QLineEdit.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/connect">@<bdi>connect</bdi></a>(lineEdit,SIGNAL(returnPressed()),&amp;w,SLOT(callme()));</p>
<p dir="auto">void callme(...)<br />
{<br />
QString text = lineEdit.text();</p>
<pre><code>hash.insert(label.text(),text())
</code></pre>
<p dir="auto">}@</p>
<p dir="auto">This should help you.</p>
]]></description><link>https://forum.qt.io/post/237198</link><guid isPermaLink="true">https://forum.qt.io/post/237198</guid><dc:creator><![CDATA[dheerendra]]></dc:creator><pubDate>Fri, 25 Jul 2014 10:28:02 GMT</pubDate></item></channel></rss>