I am developing an app for both PC and android using Qt Creator and C++. For part of my app, I have a QTableWidget that the user can add entries to and edit the information inside of the boxes.
On both PC and the AVD that I was using to test how the app would run on android, I can edit the boxes of the table no problem. However, now that I've connected an actual android phone to my pc and tested the app on there, I can't select the boxes. No matter where I tap or how much pressure I apply the boxes will not select.

And here is the application output. It's worth noting that the line "AccessibilityEvent with empty description" seems to only happen when I tap on an empty box in the table.
I e.ChickenChart: Late-enabling -Xcheck:jni
E e.ChickenChart: Unknown bits set in runtime_flags: 0x8000
W System : ClassLoader referenced unknown path:
W e.ChickenChart: Accessing hidden method Landroid/content/ContextWrapper;-\>getDisplay()Landroid/view/Display; (greylist, linking, allowed)
I QtCore : Start
I Qt : qt started
I AdrenoGLES: QUALCOMM build : 961b24f, Ib57168459a
I AdrenoGLES: Build Date : 02/24/20
I AdrenoGLES: OpenGL ES Shader Compiler Version: EV031.27.05.06
I AdrenoGLES: Local Branch :
I AdrenoGLES: Remote Branch :
I AdrenoGLES: Remote Branch :
I AdrenoGLES: Reconstruct Branch :
I AdrenoGLES: Build Config : S L 8.0.12 AArch32
I AdrenoGLES: PFP: 0x005ff113, ME: 0x005ff066
W Gralloc3: mapper 3.x is not supported
W Qt A11Y : Could not (yet) activate platform accessibility.
W Qt A11Y : AccessibilityEvent with empty description
I chatty : uid=10397(org.qtproject.example.ChickenCharts) identical 1 line
W Qt A11Y : AccessibilityEvent with empty description
W Qt A11Y : AccessibilityEvent with empty description
W Qt A11Y : AccessibilityNodeInfo with empty contentDescription: -2147483627
W Qt A11Y : AccessibilityEvent with empty description
W Qt A11Y : AccessibilityEvent with empty description
W Qt A11Y : AccessibilityNodeInfo with empty contentDescription: -2147483565
W Qt A11Y : AccessibilityEvent with empty description
W Qt A11Y : AccessibilityEvent with empty description
W Qt A11Y : AccessibilityNodeInfo with empty contentDescription: -2147483566
W Qt A11Y : AccessibilityEvent with empty description
13:05:31:
"org.qtproject.example.ChickenCharts" died.
I tried getting rid of the QScroller that I attached to the QTableWidget, thinking that the QScroller may have been somehow blocking input to the table itself. However, this didn't fix anything.
I have also tried changing the selection mode of the table, but again this didn't work. I'm at a loss as to what the issue could be.
(UPDATE):
As hyde suggested, I created a simple app that just contains a window with a QTableWidget. It is contained entirely in main() and there is only one cell in the table.
I tested it on both desktop and my phone. On desktop the cell could be edited as normal, but on android, although the cell would be highlighted when I tapped it, it would not allow me to edit it.
I have tried to fix the issue in this small test app but so far I have been unable to. I also checked to see if the ItemIsEditable flag was set for the cell, and it was. If this issue persists I may look into changing my chart to use QML.
Here is a minimal reproducible example which can be used in Qt Creator:
#include <QLayout>
#include <QTableWidget>
#include <QVBoxLayout>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *window = new QWidget();
QVBoxLayout *v_layout = new QVBoxLayout(window);
QTableWidget *table = new QTableWidget();
table->setRowCount(1);
table->setColumnCount(1);
v_layout->addWidget(table);
window->show();
return a.exec();
}
(UPDATE 2)
As musicamante recommended, I overrode the QTableWidget's event() method and printed out the events that it received to the console. Here is the event I got each time I tapped on the table:
D libTableTest_armeabi-v7a.so: QEvent::InputMethodQuery
This would appear regardless of where I tapped on the table; Even tapping on an empty space with no cells would send this event. If I did tap on a cell, I would also receive these next three lines, followed by another event a second or so after:
W Qt A11Y : AccessibilityEvent with empty description
W Qt A11Y : AccessibilityNodeInfo with empty contentDescription: -2147483635
W Qt A11Y : AccessibilityEvent with empty description
D libTableTest_armeabi-v7a.so: QEvent::Timer // this appears after a short delay
I tried setting various attributes on the table. Setting the WA_AcceptTouchEvents attribute to true will cause another event to appear when you tap anywhere on the table:
D libTableTest_armeabi-v7a.so: QEvent::TouchBegin
But otherwise there is no change in behavior. Setting WA_TouchPadAcceptSingleTouchEvents does not change the behavior or introduce any new events to the output.
I tested the AA_SynthesizeMouseForUnhandledTouchEvents, and it was set to true by default. Setting it to false removed this output whenever I tapped on a cell:
W Qt A11Y : AccessibilityEvent with empty description
W Qt A11Y : AccessibilityNodeInfo with empty contentDescription: -2147483635
W Qt A11Y : AccessibilityEvent with empty description
But the cells would also no longer be highlighted when I tapped on them.
At one point during my tests and experiments I was actually able to select a cell and open the keyboard without needing the partial fix I had made in my first answer, however after this happened I was not able to do it again and no matter how much I tapped or pressed on the cells they couldn't be edited.
I found one solution to my problem, although it has some issues. Here it is:
In order to check whether the cell in the table was actually getting any input, I connected the table's
cellClicked()signal to my own functiononTableCellClicked(). Upon testing this, I found that the cell was able to receive input and I could use this new function to execute code when I clicked on it.I then coded it so that when the cell is clicked, the table's
editItem()function is called on the item that corresponds to the cell's position. This forces the table to bring up the editor.I've tested this and now I can edit cells in the QTableWidget of my little test program. However, it's a bit finicky. Clicking a cell once will make the typing bar appear, but you have to click it again to bring up the phone's keyboard. Also, this code would have to disabled when running the app on pc, since the pc version already works perfectly fine without it.
Although this technically solves my problem, I'm going to research QML. I'll probably end up using that instead since this solution has a few flaws.
Here's the code in case anyone is interested: