I am having trouble troubleshooting this problem.
I have a QTimer that calls a slot every second.
The SLOT sends a request to server then receives the html or text and then it gets written to a document.
THen I'm reading the info of this document and pass the values to variables that end up being displayed in a GUI.
connect(timer, SIGNAL(timeout()), this, SLOT(getValue());
timer->start(1000);
...
void myProgram::getValue()
{
myFile
= new QFile (filename
);
abc = qnetworkaccessmanager.get(QNetworkRequest(url)); //abc is QNetworkReply
connect(abc, SIGNAL(readyRead()), this, SLOT(readValue()));
}
void myProgram::readValue()
{
if(file)
file->write(abc->readAll());
file->close(); // maybe not Necessary
if(file)
{
for (int i = 0; i < numberSize(); i++)
{
switch(i)
{
case 0:
{ ListofValues.append(line.section(',', 8-i, 8-i)); //ListofValues is QList <QString>
ui->lcdNumber->display(ListofValues[i]);
break;
}
case 1: ... same till case 8;
}
}
}//end if
file.close();
}
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(getValue());
timer->start(1000);
...
void myProgram::getValue()
{
myFile = new QFile (filename);
abc = qnetworkaccessmanager.get(QNetworkRequest(url)); //abc is QNetworkReply
connect(abc, SIGNAL(readyRead()), this, SLOT(readValue()));
file->open(QIODevice::ReadWrite);
}
void myProgram::readValue()
{
if(file)
file->write(abc->readAll());
file->close(); // maybe not Necessary
file->open(QIODevice::ReadOnly);
if(file)
{
QTextStream in (file);
QString line = in.readLine();
for (int i = 0; i < numberSize(); i++)
{
switch(i)
{
case 0:
{ ListofValues.append(line.section(',', 8-i, 8-i)); //ListofValues is QList <QString>
ui->lcdNumber->display(ListofValues[i]);
break;
}
case 1: ... same till case 8;
}
}
}//end if
file.close();
}
To copy to clipboard, switch view to plain text mode
Now if I refresh the file in a text editor I can see the values change, BUT in my GUI the values don't change they only get the values the very first time the program is called. After that the values don't change but remain the same.
Please any feedback is greatly appreciated I've spent a lot of time on this already.
//sample of file is
1,2,3,4,5,6,7,8,9
so I get the 9 and put it in the first element in Qlist < QString> and so on
Bookmarks