[Interest] QApplication::ApplicationStateChanged Signal Not Emitted When In EGLFS

Laszlo Agocs laszlo.agocs at qt.io
Thu Oct 19 11:14:22 CEST 2017


Hi,

Just like on other platforms where the application state concept have no meaning whatsoever, on eglfs the change to ApplicationActive is supposed be faked when the first window is becoming active. It seems this is not happening for some reason. If you can, please create a bug report in Jira (https://bugreports.qt.io).

If mobile platforms are not interesting for your project, then it could also be an option to move to some other mechanism, e.g. reimplement QWindow::exposeEvent() (or have an event filter, etc.) and start initializing when isExposed() becomes true.
Best regards,
Laszlo

From: Interest [mailto:interest-bounces+laszlo.agocs=qt.io at qt-project.org] On Behalf Of Odie McNally
Sent: tirsdag 10. oktober 2017 11.27
To: interest at qt-project.org
Subject: [Interest] QApplication::ApplicationStateChanged Signal Not Emitted When In EGLFS

Hi all,
I have a QApplication object have connected its QApplicationStateChanged signal to a slot in a custom object. In the slot, I test on the Qt::ApplicationState parameter and, if the QApplication is in the ApplicationReady state I begin drawing objects on my interface.

This works fine when run with the default plugin (I am assuming XCB but not sure how to confirm that) but when run with -platform eglfs the signal doesn't seem to be emitted. Or, perhaps more accurately, the connected slot is not called.
I can verify that the application state changes by querying and printing the QApplication::ApplicationState() at different times - the state certainly does change from 2 (ApplicationInactive) to 4 (ApplicationReady) but the signal is never emitted.
I can emit the signal myself before the call to app.exec() but this results in drawing being done before the window is initialised and positioning, scaling etc. doesn't behave as it should. I can create a single-shot timer and connect the QTimer::timeout() signal to a slot which emits the QApplication::ApplicationStateChanged signal with the correct state, but this feels a bit of a nasty hack around it.
Is there something I'm missing?
I'm developing in Debian Jessie 64bit and Qt 5.9. Also running on an Odroid XU4 but the described behaviour is evident in both environments
In case it's of benefit, I can provide some example code:
int main(int argc, char *argv[])
{
   QApplication app(argc, argv);
   std::cout << "Application state: " << app.applicationState();//Output here is: Application state: 2
   std::cin.ignore();

   MyObject* mObject = new MyObject(&engine, window, mPrint_info, &app);//App only passed here to be used in timed ApplicationState slot

   QThread::connect(&app, SIGNAL(applicationStateChanged(Qt::ApplicationState )), MyObject, SLOT(app_state(Qt::ApplicationState )));//Connect application's StateChanged() signal to handler in MyObject. Using this mechanism, we can draw elements on the view when the window has initialised. This connection works with the default platform but doesn't seem to work in eglfs.

   QTimer* myTimer = new QTimer();
   myTimer->setInterval(1000);
   QThread::connect(myTimer, SIGNAL(timeout()), MyObject, SLOT(temp()));
   myTimer->start(); //Inside temp() is an emit->app->applicationStateChanged(Qt::ApplicationReady). This is a (hopefully) temporary workaround to get drawing working properly in EGLFS.
   rc = app.exec();

  delete component;
   return rc;
}

And in MyObject:


void MyObject::app_state(Qt::ApplicationState state)//This needs to be called after the UI has initialised and all widths, heights etc. have valid values. Works well in default platform

{

    if(state == Qt::ApplicationState::ApplicationActive)

    {

        if(!this->work_set)

        {

            //Draw to GUI

            //Other logic

            this->sensors_set = true;

        }

    }

}



void LabelUpdater::temp()//When called from the QTimer slot after 1second, this allows drawing to be performed as expected running in EGLFS

{

    std::cout << "[LabelUpdater::temp()]: In temp();" << std::endl;

    if( app->applicationState() == Qt::ApplicationActive )

            emit this->app->applicationStateChanged(Qt::ApplicationActive);

}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171019/ea9dd5fa/attachment.html>


More information about the Interest mailing list