Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved] Crash when creating QQuickView from QTimer event
Forum Updated to NodeBB v4.3 + New Features

[solved] Crash when creating QQuickView from QTimer event

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stigrus
    wrote on last edited by
    #1

    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.cpp
    @
    #include "app.h"
    #include <QTimer>

    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() ) );
    

    }

    void App::createView()
    {
    view = new QQuickView();
    }
    @

    app.h
    @
    #ifndef APP_H
    #define APP_H

    #include <QGuiApplication>
    #include <QQuickView>

    class App : public QGuiApplication
    {
    Q_OBJECT
    public:
    App( int, char** );

    public slots:
    void createView();

    private:
    QQuickView *view;
    };

    #endif // APP_H
    @

    main.cpp
    @
    #include "app.h"

    int main(int argc, char *argv[])
    {
    App app(argc, argv);
    return app.exec();
    }
    @

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      I can't tell immediately what the problem is, but why are you subclassing QGuiApplication?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stigrus
        wrote on last edited by
        #3

        Thanks. Moving the QGuiApplication to main.cpp and removing it from the App class resolved the problem.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved