PDA

View Full Version : <SOLVED> How to use QGuiApplication::applicationStateChanged in normal application



cszawisza
27th May 2014, 19:04
I'm creating an application for android device, and I want to use android activities "signals" (onPause etc.). I read that I can use QGuiApplication::applicationStateChanged() signal to check my application state, but I don't know how (and if it's possible) to use this signal in 'normal' QApplication app, not QML. Or maybe if there is some other way of getting those signals in my application?

anda_skoa
27th May 2014, 19:51
http://qt-project.org/doc/qt-4.8/signalsandslots.html

Cheers,
_

cszawisza
27th May 2014, 20:18
When using AGuiApplication instead of QApplication, you just need to connect signal to slot, that's simple :) But...
Normally simple, created by QtCreator applications starts with main function like


int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();

return a.exec();
}

I can not simply change QApplication to QGuiApplication because
QWidget: Cannot create a QWidget without QApplication So I need to have a QApplication object to run my application, and while I'm using it, I can't create a QGuiApplication object... So it can not by solved using simple signal to slot connection.

ChrisW67
27th May 2014, 21:11
QApplication is-a QGuiApplication and has all those signals and more.

cszawisza
27th May 2014, 21:24
QApplication
Signals:
8 signals inherited from QGuiApplication

I don't know how I missed that... Thanks :)