How to use qtvirtualkeyboard with qwidget?
-
- You can register it at the constructor, or others before you use it. It makes the qml to
KNOWN
the type ofKeyboardPanel
- For "CM780.KeyboardPanel", it is just a
NAME
, so that you can import it in qml, for example, your do like this
qmlRegisterSingletonType<KeyboardPanel>("YourAppName.KeyboardPanel", 1, 0, "KeyboardPanel", qobject_singletontype_provider);
then you can import it like this:
import QtQuick 2.7 import QtQuick.Window 2.0 import QtQuick.VirtualKeyboard 2.0 import QtQuick.VirtualKeyboard.Settings 2.0 //you can import it here like the qt quick modules like aboves import YourAppName.KeyboardPanel 1.0
Note: for this case, I register it as singleton type, so you can invoke the method by
KeyboardPanel.yourMethod()
- You can register it at the constructor, or others before you use it. It makes the qml to
-
Hi @Vevinlong
can you share the code -
Hello @SGaist please help me
how to set input method for QLineEdit in virtual keyboard for widgets
Erorr : qt.virtualkeyboard: InputContext::sendKeyClick(): no focus to send key click - QGuiApplication::focusWindow() is: QQuickView(0x55cb3cf78130)
-
@SGaist i am attach the virtual keybord with widgets using :
QQuickView *view = new QQuickView();
QWidget *container = QWidget::createWindowContainer(view, ui->verticalLayoutWidget);
container->setMinimumSize(240, 320);
container->setMaximumSize(240, 320);//container->setAttribute(Qt::WA_AcceptTouchEvents); //container->setAttribute(Qt::WA_InputMethodEnabled, true); container->setAttribute(Qt::WA_AcceptTouchEvents); container->setFocusPolicy(Qt::NoFocus); //container->setInputMethodHints(inputMethodHints() | Qt::InputMethodHint::ImhDigitsOnly); view->setSource(QUrl("qrc:/main.qml")); // Fetch this url by right clicking on your resource file.
// view->setSource();
ui->verticalLayout->addWidget(container);
then virtual keyboard attatched with widgets but when i write in QLine edit it throw following error :
qt.virtualkeyboard: InputContext::sendKeyClick(): no focus to send key click - QGuiApplication::focusWindow() is: QQuickView(0x55cb3cf78130) -
Why are you using a QQuickView if you want to use QLineEdit ?
-
There's no need for a QQuickView to use Qt VirtualKeyboard.