ramin.lich
22nd April 2015, 20:43
i have txt file with this details :
good
bad
hi
now i want to show this words one by one after i click on Next button but with this code i only get "Good" text i mean when i click on next button doesnt show me other words. in overall my goal is when i click on next show me "good" word after i click it again show me "bad" after i click again show me "hi" here is my code with Qt 5.4
void MainWindow::on_Next_clicked()
{
ui->ShowEn->clear();
ifstream Sfile("E:\\en.txt");
getData(Sfile);
Sfile.close();
}
void MainWindow::getData(std::ifstream& myfile){
if(!myfile.eof())
{
std::string str;
getline(myfile, str);
ui->ShowEn->setText(QString::fromStdString(str));
}
}
good
bad
hi
now i want to show this words one by one after i click on Next button but with this code i only get "Good" text i mean when i click on next button doesnt show me other words. in overall my goal is when i click on next show me "good" word after i click it again show me "bad" after i click again show me "hi" here is my code with Qt 5.4
void MainWindow::on_Next_clicked()
{
ui->ShowEn->clear();
ifstream Sfile("E:\\en.txt");
getData(Sfile);
Sfile.close();
}
void MainWindow::getData(std::ifstream& myfile){
if(!myfile.eof())
{
std::string str;
getline(myfile, str);
ui->ShowEn->setText(QString::fromStdString(str));
}
}