Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. void InpFile(QLineEdit *Inp, QTextEdit *result)
  3. {
  4.     QString text = "";
  5.  
  6.     QFile file(QFileDialog().getOpenFileName());
  7.  
  8.     if (file.open(QIODevice::ReadOnly))
  9.     {
  10.  
  11.         QByteArray inpS = file.readAll();
  12.         Inp->setText(QTextCodec::codecForName("Windows-1251")->toUnicode(inpS));
  13.         result->setText("Считывание завершено");
  14.  
  15.     }
  16.     else
  17.         result->setText("Считывание не удалось");
  18.  
  19.  
  20.     file.close();
  21.  
  22. }
  23.  
  24. void OutFile(QString text, QTextEdit *result)
  25. {
  26.     QFile file(QFileDialog().getOpenFileName());
  27.  
  28.     if (file.open(QIODevice::WriteOnly))
  29.     {
  30.         QTextStream stream(&file);
  31.         stream.setCodec("Windows-1251");
  32.         stream << text;
  33.         result->setText("Запись завершена");
  34.     }
  35.  
  36.     else
  37.         result->setText("Запись не удалась");
  38.  
  39.     file.close();
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement