Andrioid Emulator no Widget GUI updates
-
wrote on 12 May 2025, 07:36 last edited by Andy314 5 Dec 2025, 07:37
Hello, here my next problem with Andriod.
I have created a simple test app with QCheckbox, QRadioButton and QTextEdit.
On the simulator I get no GUI updates (Checked, text changes) when I interact via mouse with gui.It seem only a gui update problem. When I open a simple QMessagebox via a QButton the gui indates instantly before the messagebox opens.
On real hardware all work as expected.
What can be the problem ?
-
wrote on 12 May 2025, 08:47 last edited by
This is a bug of widget based Qt build for Android
Sometimes it updates the screen but sometimes you need to update the screen manuallyI have created a function which updates screen - put next in MainWindow constructor
#include <QTimer>{ MainWindow constructor
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &MainWindow::updateScreen);
timer->start(100);}//hidden somewhere in the helper
void MainWindow::updateScreen()
{
update();
} -
wrote on 12 May 2025, 09:24 last edited by
Another bug you may face to is Android only null pointer crash of app due to QTextEdit widget
If you do not need to edit the text (just plot) - substitute it with QTextBrowser -
Hello, here my next problem with Andriod.
I have created a simple test app with QCheckbox, QRadioButton and QTextEdit.
On the simulator I get no GUI updates (Checked, text changes) when I interact via mouse with gui.It seem only a gui update problem. When I open a simple QMessagebox via a QButton the gui indates instantly before the messagebox opens.
On real hardware all work as expected.
What can be the problem ?
wrote on 12 May 2025, 09:50 last edited byI found a global solution for it (resp. ChatGPT :-) and will share it here.
class AndroidApplication : public QApplication { public: AndroidApplication(int &argc, char **argv) : QApplication(argc, argv) {} bool notify(QObject *receiver, QEvent *e) override { // Erstmal normal weiterleiten bool ok = QApplication::notify(receiver, e); // Bei jedem UpdateRequest-Event erzwingen wir einen Frame-Swap if (e->type() == QEvent::UpdateRequest) { // Prüfen, ob das Ziel ein QWidget ist if (auto w = qobject_cast<QWidget*>(receiver)) { if (auto wh = w->window()->windowHandle()) { wh->requestUpdate(); // sofortigen Flush anstoßen } } } return ok; } };
It works ! Is this ok in general and for performance issues ?
1/4