<?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] Convert listelement role to string]]></title><description><![CDATA[<p dir="auto">Hello all.Can someone show me how to convert listelement role to to string.I post the example i use to get the string but only the first listelement is succesful.The rest not.</p>
<p dir="auto">@<br />
Model.qml<br />
ListModel {<br />
id: model<br />
ListElement{names: "354873595" }<br />
ListElement{names: "354700672" }<br />
ListElement{names: "359033560" }<br />
ListElement{names: "354875672" }<br />
ListElement{names: "352500609" }<br />
}<br />
@</p>
<p dir="auto">@<br />
MainPage.qml<br />
function match() {<br />
if (topname.text == somename.text)<br />
testdialog.open()<br />
else {<br />
faildialog.open()<br />
}<br />
}<br />
Model {<br />
id: namemodel<br />
}<br />
Text {<br />
id: topname<br />
visible: false<br />
text: "2671634"<br />
}<br />
Text {<br />
id: somename<br />
visible: false<br />
text: names<br />
}@</p>
<p dir="auto">I try to use "namemodel.get(0).name" but only the first is read while the rest is not read.</p>
]]></description><link>https://forum.qt.io/topic/36336/solved-convert-listelement-role-to-string</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 22:48:16 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/36336.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 08 Jan 2014 11:59:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Sun, 12 Jan 2014 16:20:01 GMT]]></title><description><![CDATA[<p dir="auto">now i know,i will try</p>
]]></description><link>https://forum.qt.io/post/210392</link><guid isPermaLink="true">https://forum.qt.io/post/210392</guid><dc:creator><![CDATA[Traxx]]></dc:creator><pubDate>Sun, 12 Jan 2014 16:20:01 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Sun, 12 Jan 2014 16:14:55 GMT]]></title><description><![CDATA[<p dir="auto">Errr,what is break point?</p>
]]></description><link>https://forum.qt.io/post/210391</link><guid isPermaLink="true">https://forum.qt.io/post/210391</guid><dc:creator><![CDATA[Traxx]]></dc:creator><pubDate>Sun, 12 Jan 2014 16:14:55 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Sun, 12 Jan 2014 15:59:27 GMT]]></title><description><![CDATA[<p dir="auto">Did you add break points to track your code?</p>
]]></description><link>https://forum.qt.io/post/210388</link><guid isPermaLink="true">https://forum.qt.io/post/210388</guid><dc:creator><![CDATA[Vincent007]]></dc:creator><pubDate>Sun, 12 Jan 2014 15:59:27 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Sun, 12 Jan 2014 15:55:36 GMT]]></title><description><![CDATA[<p dir="auto">Weird,putting {} didn't make  <a href="http://difference.No" target="_blank" rel="noopener noreferrer nofollow ugc">difference.No</a> dialog show if use the javascript.Once i comment it out the dialog show again.</p>
]]></description><link>https://forum.qt.io/post/210387</link><guid isPermaLink="true">https://forum.qt.io/post/210387</guid><dc:creator><![CDATA[Traxx]]></dc:creator><pubDate>Sun, 12 Jan 2014 15:55:36 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Sun, 12 Jan 2014 15:22:38 GMT]]></title><description><![CDATA[<p dir="auto">{ } is missing !!</p>
<p dir="auto">@<br />
Component.onCompleted: {<br />
for(var i=0;i&lt;count;i++) {<br />
somename.text = namemodel.get(i).imeistring<br />
match()  //FUNCTION<br />
}<br />
}<br />
@</p>
]]></description><link>https://forum.qt.io/post/210381</link><guid isPermaLink="true">https://forum.qt.io/post/210381</guid><dc:creator><![CDATA[Vincent007]]></dc:creator><pubDate>Sun, 12 Jan 2014 15:22:38 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Sun, 12 Jan 2014 14:03:50 GMT]]></title><description><![CDATA[<p dir="auto">I have change the MainPage a bit to follow Vicent007 example and  it is not working but that is not the point.Why if i use "for(var i=0;i&lt;count;i++)" the match() function is not working but if i comment it out it is working with either testdialog or faildialog open.If i use it,no dialog show so i assume the match() function not working.Thank you<br />
@MainPage.qml<br />
function match() {<br />
if (topname.text == somename.text)<br />
testdialog.open()<br />
else {<br />
faildialog.open()<br />
}<br />
}<br />
Model {  //TO IMPORT Model.qml<br />
id: namemodel<br />
}<br />
Text {<br />
id: topname<br />
visible: false<br />
text: "2671634"<br />
}<br />
Text {<br />
id: somename<br />
visible: false<br />
}<br />
Component.onCompleted: {<br />
for(var i=0;i&lt;count;i++)<br />
somename.text = namemodel.get(0).imeistring<br />
match()  //FUNCTION</p>
<p dir="auto">}<br />
@</p>
]]></description><link>https://forum.qt.io/post/210365</link><guid isPermaLink="true">https://forum.qt.io/post/210365</guid><dc:creator><![CDATA[Traxx]]></dc:creator><pubDate>Sun, 12 Jan 2014 14:03:50 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Thu, 09 Jan 2014 15:31:32 GMT]]></title><description><![CDATA[<p dir="auto">Thank you very very very much for your help.Qmlscene is not available since i use nokia QtSdk and my target is symbian.I will update the title if i manage to match the string.</p>
]]></description><link>https://forum.qt.io/post/210089</link><guid isPermaLink="true">https://forum.qt.io/post/210089</guid><dc:creator><![CDATA[Traxx]]></dc:creator><pubDate>Thu, 09 Jan 2014 15:31:32 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Thu, 09 Jan 2014 15:23:52 GMT]]></title><description><![CDATA[<p dir="auto">I can print all names, so myModel.get(i).names works fine.</p>
<p dir="auto">Starting H:\Qt\Qt5.2.0\5.2.0\msvc2010_opengl\bin\qmlscene.exe...<br />
354873595<br />
354700672<br />
359033560<br />
354875672<br />
352500609</p>
]]></description><link>https://forum.qt.io/post/210088</link><guid isPermaLink="true">https://forum.qt.io/post/210088</guid><dc:creator><![CDATA[Vincent007]]></dc:creator><pubDate>Thu, 09 Jan 2014 15:23:52 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Thu, 09 Jan 2014 13:40:14 GMT]]></title><description><![CDATA[<p dir="auto">I never use console.log before but did you mean the qt message as shown?<br />
!<a href="http://imageshack.us/photo/my-images/89/3few.png/()" target="_blank" rel="noopener noreferrer nofollow ugc">http://imageshack.us/photo/my-images/89/3few.png/()</a>!</p>
]]></description><link>https://forum.qt.io/post/210081</link><guid isPermaLink="true">https://forum.qt.io/post/210081</guid><dc:creator><![CDATA[Traxx]]></dc:creator><pubDate>Thu, 09 Jan 2014 13:40:14 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Wed, 08 Jan 2014 16:22:48 GMT]]></title><description><![CDATA[<p dir="auto">try<br />
@<br />
ListModel {<br />
id: myModel<br />
ListElement{names: "354873595" }<br />
ListElement{names: "354700672" }<br />
ListElement{names: "359033560" }<br />
ListElement{names: "354875672" }<br />
ListElement{names: "352500609" }</p>
<pre><code>    Component.onCompleted: {
        for(var i=0;i&lt;count;i++)
            console.log(myModel.get(i).names)
    }
</code></pre>
<p dir="auto">}<br />
@<br />
Do you see names are printed?</p>
]]></description><link>https://forum.qt.io/post/209927</link><guid isPermaLink="true">https://forum.qt.io/post/209927</guid><dc:creator><![CDATA[Vincent007]]></dc:creator><pubDate>Wed, 08 Jan 2014 16:22:48 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Wed, 08 Jan 2014 15:58:22 GMT]]></title><description><![CDATA[<p dir="auto">Sorry for the confusion but it is complete code.I actually try multiple way to get all string but none work and "namemodel.get()" is just one of the method i try.Previous tried some of the method below.Weird is if i use listview,all the listelement data is shown but i just want to compare the listelement data with other data only.Thanks very much</p>
<p dir="auto">@MainPage.qml<br />
function match() {<br />
if (topname.text == somename.text)<br />
testdialog.open()<br />
else {<br />
faildialog.open()<br />
}<br />
}<br />
Model {<br />
id: namemodel<br />
}<br />
Text {<br />
id: topname<br />
visible: false<br />
text: "2671634"<br />
}<br />
Text {<br />
id: somename<br />
visible: false<br />
text:  namemodel.get(0).names  //ONLY WORK ON FIRST LISTELEMENT<br />
}@</p>
<p dir="auto">@MainPage.qml<br />
function match() {<br />
if (topname.text == somename.text)<br />
testdialog.open()<br />
else {<br />
faildialog.open()<br />
}<br />
}<br />
Model {<br />
id: namemodel<br />
}<br />
Text {<br />
id: topname<br />
visible: false<br />
text: "2671634"<br />
}<br />
Text {<br />
id: somename<br />
visible: false<br />
text: namemodel.names<br />
}@</p>
]]></description><link>https://forum.qt.io/post/209924</link><guid isPermaLink="true">https://forum.qt.io/post/209924</guid><dc:creator><![CDATA[Traxx]]></dc:creator><pubDate>Wed, 08 Jan 2014 15:58:22 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Wed, 08 Jan 2014 15:23:26 GMT]]></title><description><![CDATA[<p dir="auto">Please show your code completely.<br />
especially, where you call namemodel.get(i).name</p>
]]></description><link>https://forum.qt.io/post/209917</link><guid isPermaLink="true">https://forum.qt.io/post/209917</guid><dc:creator><![CDATA[Vincent007]]></dc:creator><pubDate>Wed, 08 Jan 2014 15:23:26 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Wed, 08 Jan 2014 15:17:24 GMT]]></title><description><![CDATA[<p dir="auto">ahhh,sorry a typo.The get() function work but only applied to the first element,the rest cannot be match.</p>
]]></description><link>https://forum.qt.io/post/209915</link><guid isPermaLink="true">https://forum.qt.io/post/209915</guid><dc:creator><![CDATA[Traxx]]></dc:creator><pubDate>Wed, 08 Jan 2014 15:17:24 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Convert listelement role to string on Wed, 08 Jan 2014 13:46:35 GMT]]></title><description><![CDATA[<p dir="auto">Do you mean “namemodel.get(0).names” ?<br />
Do you miss 's'?</p>
]]></description><link>https://forum.qt.io/post/209902</link><guid isPermaLink="true">https://forum.qt.io/post/209902</guid><dc:creator><![CDATA[Vincent007]]></dc:creator><pubDate>Wed, 08 Jan 2014 13:46:35 GMT</pubDate></item></channel></rss>