1

I'm writing a simple Qt application for Windows platform. I need to set input language for QPlainTextEdit for it to be non-English by default. How can I do that?

All I could find so far is non-working example:

  QApplication Application(argc, argv);

  QLocale::setDefault(QLocale::German);
  QLocale l;
  qDebug() << l.language();
  Application.inputMethod()->locale().setDefault(QLocale::German);
  qDebug() << Application.inputMethod()->locale().language();
Andy
  • 71
  • 4
  • How your `Application` is defined? Why is it not a pointer? Use `QApplication::instance()` to get current application – Alexey Jul 01 '22 at 14:25
  • @Alexey, updated the code sample. Either way it doesn't work. – Andy Jul 01 '22 at 14:29
  • try this https://stackoverflow.com/questions/13313896/changing-locale-in-qt – agent_bean Jul 01 '22 at 14:33
  • You can try also to set locale to `QPlainTextEdit` in constructor, see https://doc.qt.io/qt-6/qwidget.html#locale-prop – Alexey Jul 01 '22 at 14:38
  • But I think this is not the case. The input language is determined by the system, and the input language for your widget cannot be set other than by setting it in the Windows language settings. – Alexey Jul 01 '22 at 14:42
  • @agent_bean, changes locale but does not change input language. – Andy Jul 01 '22 at 14:45

0 Answers0