Andrioid Emulator no Widget GUI updates
-
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 ?
-
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();
} -
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 ?
I 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 ?