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. What is the difference between QQmlApplicationEngine and QQuickView?
Forum Update on Monday, May 27th 2025

What is the difference between QQmlApplicationEngine and QQuickView?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qquickview
6 Posts 3 Posters 9.9k Views
  • 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
    Stefan Monov76
    wrote on 20 Oct 2016, 11:39 last edited by
    #1

    I'm using QQmlApplicationEngine as follows:

    QGuiApplication app(argc, argv);
    
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
    app.exec();
    

    But now I want to enable multisampling for my app, and QQmlApplicationEngine doesn't seem to have a setFormat method for enabling multisampling.

    I found a way to do it with a QQmlApplicationEngine in a forum:

    QQuickWindow* window = (QQuickWindow*) engine.rootObjects().first();
    QSurfaceFormat format;
    format.setSamples(16);
    window->setFormat(format)
    

    But it relies on the first root object of the engine being a QQuickWindow, which is not documented in Qt docs. So I don't want to use that technique.

    Another way would be to skip QQmlApplicationEngine and create a QQuickView instead. This does have a setFormat method letting me enable multisampling, but I'm wondering, am I losing anything by switching from QQmlApplicationEngine to QQuickView?

    In other words, what are the differences between these two classes?

    One difference I found is this (from here):

    Unlike QQuickView, QQmlApplicationEngine does not automatically create a root window. If you are using visual items from Qt Quick, you will need to place them inside of a Window.

    This particular difference doesn't matter to me.

    Any other differences?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 20 Oct 2016, 11:54 last edited by p3c0
      #2

      @Stefan-Monov76
      The basic difference is QQmlApplicationEngine can only load QML files which have root component as Window or ApplicationWindow while QQuickView loads any QML type which inherits Item.

      But it relies on the first root object of the engine being a QQuickWindow, which is not documented in Qt docs. So I don't want to use that technique.

      If you use QQmlApplicationEngine you have to use Window or ApplicationWindow which instantiates QQuickWindow.
      So AFAIK the code you posted is the only way to set the samples.

      157

      S 1 Reply Last reply 20 Oct 2016, 11:57
      3
      • P p3c0
        20 Oct 2016, 11:54

        @Stefan-Monov76
        The basic difference is QQmlApplicationEngine can only load QML files which have root component as Window or ApplicationWindow while QQuickView loads any QML type which inherits Item.

        But it relies on the first root object of the engine being a QQuickWindow, which is not documented in Qt docs. So I don't want to use that technique.

        If you use QQmlApplicationEngine you have to use Window or ApplicationWindow which instantiates QQuickWindow.
        So AFAIK the code you posted is the only way to set the samples.

        S Offline
        S Offline
        Stefan Monov76
        wrote on 20 Oct 2016, 11:57 last edited by
        #3

        @p3c0 : Thanks. Seems like someone had too much time on their hands and spent it creating redundant classes :)

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p3c0
          Moderators
          wrote on 20 Oct 2016, 12:02 last edited by
          #4

          @Stefan-Monov76 As the docs say QQuickView is convenience subclass of QQuickWindow.

          157

          1 Reply Last reply
          0
          • T Offline
            T Offline
            thorbjorn
            wrote on 20 Oct 2016, 14:27 last edited by thorbjorn
            #5

            QQmlApplicationEngine is a convenience class introduced in Qt 5.1, with several advantages over QQuickView:

            • Can also be used for non-graphical purposes (so whether the root object is a QQuickView depends on the QML you're loading).
            • Automates a bunch of things (Qt.quit(), translations, file selectors)
            • Allows subclasses like ApplicationWindow to be used as root item (whereas you would have a Window nested in a Window when using a QQuickView, I'm not sure what it does in that case)

            While technically redundant, I think it was a welcome addition since it saves a lot of boilerplate code.

            S 1 Reply Last reply 20 Oct 2016, 15:21
            3
            • T thorbjorn
              20 Oct 2016, 14:27

              QQmlApplicationEngine is a convenience class introduced in Qt 5.1, with several advantages over QQuickView:

              • Can also be used for non-graphical purposes (so whether the root object is a QQuickView depends on the QML you're loading).
              • Automates a bunch of things (Qt.quit(), translations, file selectors)
              • Allows subclasses like ApplicationWindow to be used as root item (whereas you would have a Window nested in a Window when using a QQuickView, I'm not sure what it does in that case)

              While technically redundant, I think it was a welcome addition since it saves a lot of boilerplate code.

              S Offline
              S Offline
              Stefan Monov76
              wrote on 20 Oct 2016, 15:21 last edited by
              #6

              @thorbjorn : Thanks! Very useful answer (unlike the docs, which are really lacking on this :) ). I'll use the QQmlApplicationEngine way.

              1 Reply Last reply
              0

              6/6

              20 Oct 2016, 15:21

              • Login

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