user6285273
user6285273

Reputation:

Call a function when screen is unlocked

I have opened and focused app on android phone, and I lock the screen. When I unlock it, I want to call a specific function.

I was thinking about Qt.application.state, but how to call function when it has changed?

Upvotes: 0

Views: 361

Answers (1)

Evgeny
Evgeny

Reputation: 4010

You searching for void QGuiApplication::applicationStateChanged(Qt::ApplicationState state).

From Qt documentation:

void QGuiApplication::applicationStateChanged(Qt::ApplicationState state)

This signal is emitted when the state of the application changes.

This function was introduced in Qt 5.2.

Just connect to this signal at your C++ part of code, check state == Qt::ApplicationActive and trigger some function inside you QML part.

Upvotes: 2

Related Questions