this is my first question here, i always found the answers i need but today, that "always" has ended haha. My problem is that i'm trying to read a text file with QFile and QTextStream and save the values inside an STL vector. When i try to read the vector, I obtain that is empty(forgive any mistakes with my english, is no my first language). Here i leave you the methods.
bool TGraphic::process_data( void )
{
bool openingOk = false;
QString line;
if(QFile::exists( this->input_file.fileName() ))
{
openingOk = this->input_file.open(QIODevice::Text | QIODevice::ReadOnly);
QTextStream flujo(&input_file);
while(!(flujo.atEnd()))
{
line = flujo.readLine();
this->data.push_back( line.toInt() ); // data is std::vector<int> data;
}
}
return openingOk;
}
The compiler doesn't give me any errors but when i do this
void Ventana::on_pbGraphic_clicked()
{
imgGen = new TGraphic(fileName);
std::vector<int> aux(imgGen->getVector());
bool dataOk, graphicOk;
img = new QPixmap(400, 300);
dataOk = imgGen->process_data();
graphicOk = imgGen->process_graphic(*img);
if(dataOk && graphicOk && !(aux.empty())) // ** THE LAS CONDITION GAVE ME FALSE **
{
//ui->labGraphic->setPixmap(*img);
ui->labNombreArchivo->setText(QString::number(aux[0])); // I TRIED TO GET THE
} // THE FIRST VALUE OF
else // THE VECTOR AND THE
{ // PROGRAM FAILS THERE.
ui->labGraphic->setText("Error.");
}
}
in dialog.cpp i get a false. Can you guys help to see where is the problem? If you need extra information ask me. Thanks!