<?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[How to load the Integer value from txt file]]></title><description><![CDATA[<p dir="auto">I have added in a new connect , which is when LOAD button is clicked, i can get my the value from txt file which is from loadValue() function, but I could not obtain it,<br />
I did not get debug message from this function too,<br />
please advise where i did wrong,</p>
<p dir="auto">By the way, i would like to get Integer value only, i don't want the words.</p>
<p dir="auto">@#include "dialog.h"<br />
#include "ui_dialog.h"</p>
<p dir="auto">#include &lt;QDebug&gt;<br />
#include &lt;QFile&gt;<br />
#include &lt;QTextStream&gt;</p>
<p dir="auto">Dialog::Dialog(QWidget *parent) :<br />
QDialog(parent),<br />
ui(new Ui::Dialog)<br />
{<br />
ui-&gt;setupUi(this);</p>
<pre><code>timer = new QTimer(this);

cam = cvCaptureFromCAM(-1);

if(cam==NULL)
    qDebug()&lt;&lt;"error";

timer-&gt;start(30);
connect(timer,SIGNAL(timeout()),this,SLOT(getFrame()));

connect(ui-&gt;hueSlide1,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));
connect(ui-&gt;hueSlide2,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));
connect(ui-&gt;satSlide1,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));
connect(ui-&gt;satSlide2,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));
connect(ui-&gt;lumSlide1,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));
connect(ui-&gt;lumSlide2,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));
connect(ui-&gt;load,SIGNAL(clicked()),this,SLOT(loadValue()));
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void Dialog::getFrame()<br />
{<br />
frame = cvQueryFrame(cam);<br />
QImage image = QImage ((const uchar*)frame-&gt;imageData,frame-&gt;width,frame-&gt;height,QImage::Format_RGB888).rgbSwapped();//rgbSwapped() make color better<br />
ui-&gt;original-&gt;setPixmap(QPixmap::fromImage(image));<br />
}</p>
<p dir="auto">void Dialog::prcFrame()<br />
{<br />
imgHSV= cvCreateImage(cvSize(frame-&gt;width,frame-&gt;height),IPL_DEPTH_8U,3);<br />
cvCvtColor(frame,imgHSV,CV_BGR2HSV);</p>
<pre><code>//threshed , get value from slider value
</code></pre>
<p dir="auto">// QImage filterImg = QImage ((const uchar*)imgHSV-&gt;imageData,imgHSV-&gt;width,imgHSV-&gt;height,QImage::Format_RGB888);<br />
// ui-&gt;filter-&gt;setPixmap(QPixmap::fromImage(filterImg));<br />
}</p>
<p dir="auto">void Dialog::saveValue()<br />
{<br />
int h_slide1 = ui-&gt;hueSlide1-&gt;value();<br />
int h_slide2 = ui-&gt;hueSlide2-&gt;value();<br />
int s_slide1 = ui-&gt;satSlide1-&gt;value();<br />
int s_slide2 = ui-&gt;satSlide2-&gt;value();<br />
int l_slide1 = ui-&gt;lumSlide1-&gt;value();<br />
int l_slide2 = ui-&gt;lumSlide2-&gt;value();<br />
QFile valueHSV("/home/pi/valueHSV/hsv.txt");<br />
if(!valueHSV.open(QIODevice::WriteOnly|QIODevice::Text))<br />
{<br />
qDebug() &lt;&lt; "cannot open file for writing"&lt;&lt;endl;<br />
return;<br />
}<br />
QTextStream hsv(&amp;valueHSV);<br />
hsv &lt;&lt; "&lt;HUE LOW&gt;" &lt;&lt;h_slide1&lt;&lt;endl;<br />
hsv &lt;&lt; "&lt;HUE HIGH&gt;" &lt;&lt;h_slide2&lt;&lt;endl;<br />
hsv &lt;&lt; "&lt;SAT LOW&gt;" &lt;&lt;s_slide1&lt;&lt;endl;<br />
hsv &lt;&lt; "&lt;SAT HIGH&gt;" &lt;&lt;s_slide2&lt;&lt;endl;<br />
hsv &lt;&lt; "&lt;LUM LOW&gt;" &lt;&lt;l_slide1&lt;&lt;endl;<br />
hsv &lt;&lt; "&lt;LUM HIGH&gt;" &lt;&lt;l_slide2&lt;&lt;endl;<br />
//qDebug() &lt;&lt; "H_low" &lt;&lt; h_slide1;<br />
//qDebug() &lt;&lt; "H_high" &lt;&lt; h_slide2;<br />
<a href="//valueHSV.close" target="_blank" rel="noopener noreferrer nofollow ugc">//valueHSV.close</a>();</p>
<p dir="auto">}</p>
<p dir="auto">void Dialog::loadValue()<br />
{<br />
QStringList list;<br />
QFile valueHSV("/home/pi/valueHSV/hsv.txt");<br />
if(!valueHSV.open(QIODevice::ReadOnly|QIODevice::Text))<br />
{<br />
qDebug() &lt;&lt; "cannot open file for reading"&lt;&lt;endl;<br />
return;<br />
}<br />
QTextStream hsv(&amp;valueHSV);<br />
while (!hsv.atEnd())<br />
{<br />
QString load=hsv.readLine();<br />
if(load.isNull())<br />
break;<br />
}<br />
foreach(QString str, list)<br />
{<br />
int h1 = str.toInt();<br />
qDebug() &lt;&lt; "value"&lt;&lt;h1;<br />
}<br />
return;<br />
}</p>
<p dir="auto">Dialog::~Dialog()<br />
{<br />
timer-&gt;stop();<br />
cvReleaseCapture(&amp;cam);</p>
<pre><code>delete ui;
</code></pre>
<p dir="auto">}@</p>
]]></description><link>https://forum.qt.io/topic/43216/how-to-load-the-integer-value-from-txt-file</link><generator>RSS for Node</generator><lastBuildDate>Fri, 19 Jun 2026 04:52:38 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/43216.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 02 Jul 2014 05:54:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to load the Integer value from txt file on Wed, 02 Jul 2014 11:31:07 GMT]]></title><description><![CDATA[<p dir="auto">after i change to QXmlStreamWriter,<br />
I can get a xml output, now i would like to load the save value from the xml file,<br />
i meet some problem.<br />
i could get QString convert back to int , what i do is like below, please advise<br />
@QXmlStreamReader hsv(&amp;valueHSV);<br />
hsv.readNext();<br />
while(!hsv.atEnd())<br />
{<br />
if(hsv.isStartElement())<br />
{<br />
if(<a href="http://hsv.name" target="_blank" rel="noopener noreferrer nofollow ugc">hsv.name</a>()=="HSV")<br />
{<br />
if(<a href="http://hsv.name" target="_blank" rel="noopener noreferrer nofollow ugc">hsv.name</a>()=="HUE LOW")</p>
<pre><code>                ui-&gt;hueSlide1-&gt;setValue(QString::toInt(hsv.readElementText()));
        }
    }
}@
</code></pre>
]]></description><link>https://forum.qt.io/post/234332</link><guid isPermaLink="true">https://forum.qt.io/post/234332</guid><dc:creator><![CDATA[YDYD]]></dc:creator><pubDate>Wed, 02 Jul 2014 11:31:07 GMT</pubDate></item><item><title><![CDATA[Reply to How to load the Integer value from txt file on Wed, 02 Jul 2014 08:03:09 GMT]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">Thanks for you all reply, and i appreciate</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/void">@<bdi>void</bdi></a> Dialog::loadValue()<br />
{<br />
QStringList list;<br />
QFile valueHSV("/home/pi/valueHSV/hsv.txt");<br />
if(!valueHSV.open(QIODevice::ReadOnly|QIODevice::Text))<br />
{<br />
qDebug() &lt;&lt; "cannot open file for reading"&lt;&lt;endl;<br />
return;<br />
}<br />
QTextStream hsv(&amp;valueHSV);<br />
while (!hsv.atEnd())<br />
{<br />
QString load=hsv.readLine();<br />
if(load.isNull())<br />
break;<br />
list &lt;&lt; load;<br />
}<br />
/* foreach(QString str, list)<br />
{<br />
int h1 = str.toInt();<br />
qDebug() &lt;&lt; "value"&lt;&lt;h1;<br />
}*/<br />
return;<br />
}@</p>
<p dir="auto">I have hide the foreach loop,</p>
<p dir="auto">and pass the value to list  in line16 ,</p>
<p dir="auto">for this situation, i was able to read all the thing inside txt file,</p>
<p dir="auto">the output that i read is<br />
@HSV ("&lt;HUE LOW&gt;48")</p>
<p dir="auto">HSV ("&lt;HUE LOW&gt;48", "&lt;HUE HIGH&gt;124")</p>
<p dir="auto">HSV ("&lt;HUE LOW&gt;48", "&lt;HUE HIGH&gt;124", "&lt;SAT LOW&gt;79")</p>
<p dir="auto">HSV ("&lt;HUE LOW&gt;48", "&lt;HUE HIGH&gt;124", "&lt;SAT LOW&gt;79", "&lt;SAT HIGH&gt;165")</p>
<p dir="auto">HSV ("&lt;HUE LOW&gt;48", "&lt;HUE HIGH&gt;124", "&lt;SAT LOW&gt;79", "&lt;SAT HIGH&gt;165", "&lt;LUM LOW&gt;63")</p>
<p dir="auto">HSV ("&lt;HUE LOW&gt;48", "&lt;HUE HIGH&gt;124", "&lt;SAT LOW&gt;79", "&lt;SAT HIGH&gt;165", "&lt;LUM LOW&gt;63", "&lt;LUM HIGH&gt;205") @</p>
<p dir="auto">I do not want to get the &lt;HUE LOW&gt;<br />
but only read the integer, and get my slider to the value position,<br />
is this possible?</p>
]]></description><link>https://forum.qt.io/post/234310</link><guid isPermaLink="true">https://forum.qt.io/post/234310</guid><dc:creator><![CDATA[YDYD]]></dc:creator><pubDate>Wed, 02 Jul 2014 08:03:09 GMT</pubDate></item><item><title><![CDATA[Reply to How to load the Integer value from txt file on Wed, 02 Jul 2014 07:48:49 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="IamSumit" date="1404286234"]<a class="plugin-mentions-user plugin-mentions-a" href="/user/connect">@<bdi>connect</bdi></a>(ui-&gt;hueSlide1,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
connect(ui-&gt;hueSlide2,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
connect(ui-&gt;satSlide1,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
connect(ui-&gt;satSlide2,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
connect(ui-&gt;lumSlide1,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
connect(ui-&gt;lumSlide2,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
@<br />
You didn't pass an integer parameter to each slot.[/quote]</p>
<p dir="auto">That's actually ok in this case, although possibly suboptimal. A signal can be connected to a slot with a shorter signature. The slot Dialog::saveValue saves values for each of the 6 sliders each time any one of them is modified by accessing the sliders directly.</p>
]]></description><link>https://forum.qt.io/post/234302</link><guid isPermaLink="true">https://forum.qt.io/post/234302</guid><dc:creator><![CDATA[jeremy_k]]></dc:creator><pubDate>Wed, 02 Jul 2014 07:48:49 GMT</pubDate></item><item><title><![CDATA[Reply to How to load the Integer value from txt file on Wed, 02 Jul 2014 07:30:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/connect">@<bdi>connect</bdi></a>(ui-&gt;hueSlide1,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
connect(ui-&gt;hueSlide2,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
connect(ui-&gt;satSlide1,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
connect(ui-&gt;satSlide2,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
connect(ui-&gt;lumSlide1,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
connect(ui-&gt;lumSlide2,SIGNAL(valueChanged(int)),this,SLOT(saveValue()));<br />
@<br />
You didn't pass an integer parameter to each slot.</p>
]]></description><link>https://forum.qt.io/post/234304</link><guid isPermaLink="true">https://forum.qt.io/post/234304</guid><dc:creator><![CDATA[IamSumit]]></dc:creator><pubDate>Wed, 02 Jul 2014 07:30:34 GMT</pubDate></item><item><title><![CDATA[Reply to How to load the Integer value from txt file on Wed, 02 Jul 2014 07:21:05 GMT]]></title><description><![CDATA[<p dir="auto">It might help to post a shorter, more focused example. I say this both for readers and for the poster.</p>
<p dir="auto">From what I see, the Dialog::loadValue() attempts to parse integer values from the elements of the QStringList list using a foreach loop at line 94. Unfortunately, perhaps due to a typo in the example, list is never initialized. My guess is that the QString load from line 90 is supposed to be tokenized based on some separator. This is probably supposed to happen based on the result of the readLine() at line 90.</p>
]]></description><link>https://forum.qt.io/post/234300</link><guid isPermaLink="true">https://forum.qt.io/post/234300</guid><dc:creator><![CDATA[jeremy_k]]></dc:creator><pubDate>Wed, 02 Jul 2014 07:21:05 GMT</pubDate></item></channel></rss>