Qt6.4 QLineEdit and Virtual Keyboard Difficulties On Android
-
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.
-
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.
@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-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.
@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.
-
@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.
@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.