Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qtvirtualkeyboard in QWidget App
Forum Updated to NodeBB v4.3 + New Features

qtvirtualkeyboard in QWidget App

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 191 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MarKus12
    wrote on last edited by
    #1

    My QWidget based -none QML- app has a mainwindow and several forms.
    I use Qt5.15.8 and gcc or clang to compile it.
    I googled now for 2 days and tried to understand the abstract documentation given.

    QT_IM_MODULE is set

    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
    

    before creating

    QApplication a(argc, argv);
    

    I also did overwrite the focusInEvent of a created subclass myLineEdit
    mylineedit.h:

    #include <QLineEdit>
    #include <QWidget>
    
    class myLineEdit : public QLineEdit
    {
        Q_OBJECT
    public:
        //myLineEdit();
    
        explicit myLineEdit(QWidget *parent = nullptr);
    
    protected:
        void focusInEvent(QFocusEvent *);
        void focusOutEvent(QFocusEvent *);
    };
    

    with mylineedit.cpp:

    myLineEdit::myLineEdit(QWidget *parent) : QLineEdit(parent)
    {
    }
    
    void myLineEdit::focusInEvent(QFocusEvent *)
    {
        qWarning() << "myLineEdit :FocusInEvent activates kbd";
        setAttribute(Qt::WA_InputMethodEnabled, true);
        QApplication::inputMethod()->show();
    }
    
    void myLineEdit::focusOutEvent(QFocusEvent *)
    {
        qWarning() << "myLineEdit :FocusOutEvent hides kbd";
        QApplication::inputMethod()->hide();
    
    }
    

    Running the app for desktop it shows the vkbd.
    Running the cross compiled app on target, it don't.
    The basic example does run fine on the target.

    I did try to integrate a .qml file in my app to make define an input panel, like documentation requested. So far i came up with:

    import QtQuick 2.0
    import QtQuick.VirtualKeyboard 2.1
    
    
    Item {
       id: root
       InputPanel {
            id: inputPanel
            width: parent.width
            height: parent.height/3;
            y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height
            anchors.left: parent.left
            anchors.right: parent.right
        }
    }
    

    Currently i suspect that there might be an additional input.Method needed.
    Does anybody can point me in the right direction. (QML curses would help, i know)

    Thanks, appreciate it.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MarKus12
      wrote on last edited by
      #2

      the whole idea of integrating a Qt Virtual keyboard in a QWidget might be not a great one.
      I found QQuickWidget and QQuickView attempts which both deal with integrating qml code into
      your QWidget application.

      But I couldn't find a way to only use the qt virtual keyboard without rewriting the ui then.

      Well at this point i don't understand the documentation under:
      https://doc.qt.io/qt-5/qtvirtualkeyboard-index.html
      where it says:

      Supports both Qt Quick and Qt Widgets applications.

      How is that feature meant?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved