Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QQuickwidget does not call the virtual keyboard in ios
Forum Updated to NodeBB v4.3 + New Features

QQuickwidget does not call the virtual keyboard in ios

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qquickwidgetiosvirtualkeyboard
3 Posts 2 Posters 1.1k Views 2 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.
  • J Offline
    J Offline
    J.Hilk
    Moderators
    wrote on 28 Nov 2018, 09:47 last edited by
    #1

    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 code

    I 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 the QML - 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 ;-)


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    R 1 Reply Last reply 28 Nov 2018, 11:46
    0
    • J J.Hilk
      28 Nov 2018, 09:47

      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 code

      I 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 the QML - 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 ;-)

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 28 Nov 2018, 11:46 last edited by raven-worx
      #2

      @J.Hilk
      just a shot in the dark:
      try playing with QInputMethod::setVisible() at some points in your codee

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      J 1 Reply Last reply 28 Nov 2018, 12:31
      1
      • R raven-worx
        28 Nov 2018, 11:46

        @J.Hilk
        just a shot in the dark:
        try playing with QInputMethod::setVisible() at some points in your codee

        J Offline
        J Offline
        J.Hilk
        Moderators
        wrote on 28 Nov 2018, 12:31 last edited by
        #3

        @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 with QQuickItem as it's very base class.

        I could look into creating my own myTextInput Item that handles the QInputMethod-Query


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        0

        1/3

        28 Nov 2018, 09:47

        • Login

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