[solved] Crash when creating QQuickView from QTimer event
I try to create a QQuickView in a function that is triggered by a timer, but it triggers an exception. (The inferior stopped because it triggered an exception. ...read access violation...) If I create a QQuickView manually before the timer triggers the function that creates a QQuickView, the program will not crash.
Anybody know why this happens? What am I doing wrong?
A bit of an bad explanation, but i hope the code explais it better.
App::App( int argc, char* argv )
: QGuiApplication( argc, argv )
, view( NULL )
// If the line below is included the program works
//QQuickView* tempView = new QQuickView();
QTimer::singleShot( 5000, this, SLOT( createView() ) );
view = new QQuickView();
class App : public QGuiApplication
App( int, char** );
#endif // APP_H
int main(int argc, char *argv)
App app(argc, argv);
I can't tell immediately what the problem is, but why are you subclassing QGuiApplication?
Thanks. Moving the QGuiApplication to main.cpp and removing it from the App class resolved the problem.