Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt6.4 QLineEdit and Virtual Keyboard Difficulties On Android
Forum Updated to NodeBB v4.3 + New Features

Qt6.4 QLineEdit and Virtual Keyboard Difficulties On Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 536 Views
  • 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.
  • KenAppleby 0K Offline
    KenAppleby 0K Offline
    KenAppleby 0
    wrote on last edited by
    #1

    QT6.4 Android

    I have a BaseWidget class, multiple copies of which are laid out as rows in a parent widget. Each BaseWidget contains a "name" QLabel, the contents of which I want to be editable in response to a long-touch gesture. The single touch is for object selection.

    The following code is my latest effort, and it is close to working. The function that is invoked on a long touch gesture is:

    void BaseWidget::startLineEdit()
    {
      mLineEdit = new QLineEdit{ mLineEditLabel };
      mLineEdit->resize(mLineEditLabel->size());
      mLineEdit->setText(mLineEditLabel->text());
      connect(mLineEdit, &QLineEdit::editingFinished, this, &BaseWidget::handleEditingFinished);
      mLineEdit->show();
      mLineEdit->setFocus(Qt::OtherFocusReason);
    }
    

    It creates a new QLineEdit as a child of the name label and attempts to start the editing by giving the QLineEdit the focus.

    The problem is that, while the QLineEdit appears open for editing, the cursor is shown and editing appears to start, there is no virtual keyboard. The system keyboard does not appear.
    It is possible to get the virtual keyboard to appear by further long touches and choosing a "Select All" option, but this is far from satisfactory.

    Any help with this would be much appreciated.

    TomZT 1 Reply Last reply
    0
    • KenAppleby 0K KenAppleby 0

      QT6.4 Android

      I have a BaseWidget class, multiple copies of which are laid out as rows in a parent widget. Each BaseWidget contains a "name" QLabel, the contents of which I want to be editable in response to a long-touch gesture. The single touch is for object selection.

      The following code is my latest effort, and it is close to working. The function that is invoked on a long touch gesture is:

      void BaseWidget::startLineEdit()
      {
        mLineEdit = new QLineEdit{ mLineEditLabel };
        mLineEdit->resize(mLineEditLabel->size());
        mLineEdit->setText(mLineEditLabel->text());
        connect(mLineEdit, &QLineEdit::editingFinished, this, &BaseWidget::handleEditingFinished);
        mLineEdit->show();
        mLineEdit->setFocus(Qt::OtherFocusReason);
      }
      

      It creates a new QLineEdit as a child of the name label and attempts to start the editing by giving the QLineEdit the focus.

      The problem is that, while the QLineEdit appears open for editing, the cursor is shown and editing appears to start, there is no virtual keyboard. The system keyboard does not appear.
      It is possible to get the virtual keyboard to appear by further long touches and choosing a "Select All" option, but this is far from satisfactory.

      Any help with this would be much appreciated.

      TomZT Offline
      TomZT Offline
      TomZ
      wrote on last edited by
      #2

      @KenAppleby-0 The widgets library is still shipped, but it is not the main way to create mobile applications. I really never even tried it.

      Can I ask, is there a reason you use C++ / QWidgets for creating user interfaces? The QML stuff has been made to replace QWidgets and has been available and on the market for 14 years.

      It is MUCH easier to make scalable user interfaces in QML for mobile.

      KenAppleby 0K 2 Replies Last reply
      0
      • TomZT TomZ

        @KenAppleby-0 The widgets library is still shipped, but it is not the main way to create mobile applications. I really never even tried it.

        Can I ask, is there a reason you use C++ / QWidgets for creating user interfaces? The QML stuff has been made to replace QWidgets and has been available and on the market for 14 years.

        It is MUCH easier to make scalable user interfaces in QML for mobile.

        KenAppleby 0K Offline
        KenAppleby 0K Offline
        KenAppleby 0
        wrote on last edited by KenAppleby 0
        #3

        @TomZ Fair question. The answer is inertia more than anything. I am familiar with QWidgets, and daunted by the task of learning how to implement the application with QML.

        The widgets application is centred on a QGraphicsScene which is populated with QGraphicsPixmapItems on demand as the user pans and zooms the view. The QGraphicsPixmapItems are created from images that are retrieved asynchronously, either from a local database cache or from a remote server.

        I agree the UI would be far better implemented in QML/Quick/Controls, while leaving the image logic in C++, but I don't yet know how to do this, especially using only declarative language.

        1 Reply Last reply
        0
        • TomZT TomZ

          @KenAppleby-0 The widgets library is still shipped, but it is not the main way to create mobile applications. I really never even tried it.

          Can I ask, is there a reason you use C++ / QWidgets for creating user interfaces? The QML stuff has been made to replace QWidgets and has been available and on the market for 14 years.

          It is MUCH easier to make scalable user interfaces in QML for mobile.

          KenAppleby 0K Offline
          KenAppleby 0K Offline
          KenAppleby 0
          wrote on last edited by
          #4

          @TomZ A better reason is that the combination of QGraphicsScene/QGraphicsView with a QOpenGL Widget as the QGraphicsView viewport performs brilliantly, while the QML equivalent is too laggy to be usable in my application.

          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