Advertisement
Guest User

Qt in Console for Win: Russian and Ukrainian input / output

a guest
Oct 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <Windows.h>
  4.  
  5. #include <QDebug>
  6.  
  7. // std::string support for qDebug()
  8. QDebug operator<<(QDebug out, const std::string& str) {
  9.     out << str.c_str();
  10.     return out;
  11. }
  12.  
  13. int main() {
  14.     SetConsoleCP(1251);
  15.     SetConsoleOutputCP(1251);
  16.  
  17.     QTextStream s(stdin);
  18.     qDebug() << "Введіть слово або фразу:";
  19.     std::string str = s.readLine().toStdString();
  20.  
  21.     qDebug() << "\nstd::string:" << str;
  22.     qDebug() << "std::list з коробки:"
  23.              << QString::fromStdString(str)
  24.                 .split(QRegExp("\\s+"))
  25.                 .toStdList();
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement