Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Virtual Keyboard Language not set



  • Re: Changing QtVirtualKeyboard Language Without Keyboard Button

    Just for information: using Qt 5.13.2 version, before starting application I set the QT_IM_MODULE=qtvirtualkeyboard. So virtual keyboard pops up properly in English language.

    Query:
    Trying to set the virtual keyboard language in c++ at the startup of application. If I write code
    QLocale curLocal(QLocale("ar_AR"));
    QLocale::setDefault(curLocal); // This code works properly if write before QApplication

    QApplication a(argc, argv);

    QLocale curLocal(QLocale("ar_AR"));
    QLocale::setDefault(curLocal); // This code doesnt work if write after QApplication

    why above code doesnt work after QApplication, is there any bug?

    I have also gone through some links & code which is available in forum and tried but it is not working for me.

    Below is one of the solution provided in qt forum but not working for me. Just want to understand what I am missing here.
    QQuickView topWindow = static_cast<QQuickView>(QGuiApplication::topLevelWindows().last());
    qDebug() << "Root Object\t" << topWindow->rootObject();
    qDebug() << "Root Object Children\t" << topWindow->rootObject()->children();
    QObject* keyboard = topWindow->rootObject()->findChild<QObject*>("keyboard");
    QMetaObject::invokeMethod(keyboard, "changeInputLanguage", Q_ARG(QVariant, true));

    I have line edit in window where virtual keyboard pops up when pressed in lineedit. English language keyboard is visible & works properly.
    Now want to set other language e.g. arabic at the initialisation of program after "QApplication app" block of code.

    when I used above code for getting toplevelwindow my application is getting crashed. I have added that code in initialisation of window.
    Where can I put the above code to set the virtual keyboard language and is anything missed in the code?


Log in to reply