QQuickwidget does not call the virtual keyboard in ios
-
Hi everyone,
I just wanted to ask, if anyone encountered this bug as well:
https://bugreports.qt.io/browse/QTBUG-63157
and has a workaround/fix for it?It's over a year old, but still no progress with it.
I'm not familiar enought with QGuiApplication to actually dabble with the source codeI made my own workaround, with whom I'm not really that satisifed with.
Currently I create a new normal QLineEdit, that is invisible and forward the textChanged event to theQML - LineEdit
That creates the needed events to call forth a virtual Keyboard.
class iOSLineEdit : public QLineEdit { Q_OBJECT public: explicit iOSLineEdit(QWidget *parent = nullptr); Q_INVOKABLE QString newUuid(){return QUuid::createUuid().toString();} public slots: void initLineEdit(const QString &text, const QString &uuid); signals: void currentTextChanged(const QString &uuid, const QString &text); void currentEditFinsihed(const QString &uuid); protected: QString m_Uuid; }; //------ iOSLineEdit::iOSLineEdit(QWidget *parent) : QLineEdit (parent) { setMaximumSize(QSize(0,0)); connect(this, &QLineEdit::textChanged, this, [=](const QString &text)->void{ if( !m_Uuid.isEmpty()) { emit currentTextChanged(m_Uuid, text); } }); connect(this, &QLineEdit::editingFinished, this, [=]()->void{ if(!m_Uuid.isEmpty()) emit currentEditFinsihed(m_Uuid); m_Uuid.clear(); clear(); setEnabled(false); hide(); }); lower(); hide(); } void iOSLineEdit::initLineEdit(const QString &text, const QString &uuid) { m_Uuid.clear(); setText(text); m_Uuid = uuid; setEnabled(true); show(); setFocus(); } //qml TextInput { id: tInput ...... } MouseArea { id: iosClick anchors.fill: tInput property string uuid: BackEnd.newUuid() visible: Qt.platform.os === "ios" onClicked: { BackEnd.initLineEdit(tInput.text,iosClick.uuid); } Connections{ target: BackEnd onCurrentTextChanged:{ if(uuid === iosClick.uuid ) { tInput.text = text } } } }
I think there has to be a
better
way for it x)
Hopefully, this at the least, brings some more focus/votes on the issue ;-) -
@J.Hilk
just a shot in the dark:
try playing with QInputMethod::setVisible() at some points in your codee -
@raven-worx
mmh, I'm unsure but I'll look into it.However that gave me an idea. The
TextInput
QML-Item should have it's own c++ class(I'm however unsure what it's called), somewhere withQQuickItem
as it's very base class.I could look into creating my own
myTextInput
Item that handles the QInputMethod-Query