I want to load the data from text file ..and i successfully did it by loading it in textbrowser....Now I want to load the specific characters into line edit whenever I encounter 0 in string of text file .....I succededd here but the program shows errror
Error message:::The application has requested the runtime to terminate in a unusual way
Please contact the application support team for more information
My Code::
Qt Code:
  1. void MainWindow::on_pushButton_clicked()
  2. {
  3. QString filename = QFileDialog::getOpenFileName(this, tr("wew"),"",tr("allfiles(*.txt)"));
  4. QFile file(filename);
  5. if(file.open(QIODevice::ReadOnly | QIODevice::Text));
  6. {
  7. QTextStream in(&file);
  8. //QString mm;
  9.  
  10. QString line;
  11. //char *ptr;
  12. // QByteArray ba;
  13. while (!in.atEnd())
  14. {
  15. line = in.readLine(0);//reads whole text file and loads it to Qstring line
  16. // ba=line.toLatin1();
  17.  
  18.  
  19. //line.fromLatin1(ba,-1);
  20. ui->textBrowser->setText(line);
  21. }
  22.  
  23. for(int i=0;i<=line.length();++i)
  24. {
  25.  
  26. // ba=mm.toLatin1();
  27. //*ptr=ba.data();
  28. // if(line.at(i)==QChar('s'))
  29. //{
  30. //line.append("ssss");
  31. //}
  32. QChar ch=line.at(i).toAscii();
  33. int chvalue=ch.toAscii();
  34. if(chvalue==48)
  35. {
  36. ui->lineEdit->setText(ch);
  37. }
  38. }
  39.  
  40. file.close();
  41.  
  42. }
  43. }
To copy to clipboard, switch view to plain text mode