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] ApplicationWindow in qml gives error
Forum Updated to NodeBB v4.3 + New Features

[Solved] ApplicationWindow in qml gives error

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.4k 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.
  • A Offline
    A Offline
    Abin
    wrote on last edited by
    #1

    I have created a Qt Quick Application and in qml file i give the below code:

    @import QtQuick 2.2
    import QtQuick.Controls 1.1

    ApplicationWindow
    {
    id: root

    width: 100
    height: 100
    
    color: "red"
    

    }
    @

    This gives me the below message and the screen will not display anything :

    _QQuickView only supports loading of root objects that derive from QQuickItem.

    If your example is using QML 2, (such as qmlscene) and the .qml file you
    loaded has 'import QtQuick 1.0' or 'import Qt 4.7', this error will occur.

    To load files with 'import QtQuick 1.0' or 'import Qt 4.7', use the
    QDeclarativeView class in the Qt Quick 1 module._

    I have seen the same code used in many tutorials without any issues Your text to link here...be":http://www.youtube.com/watch?v=_6_F6Kpjd-Q

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      you need to use QQmlApplicationEngine. Below is a main.cpp file that should work for you.

      @
      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      #include <QQuickWindow>

      int main(int argc, char *argv[])
      {
      QGuiApplication app(argc, argv);
      QQmlApplicationEngine engine;
      engine.load(QUrl("qml/convQML/main.qml"));
      QObject *topLevel = engine.rootObjects().value(0);
      QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
      window->show();
      return app.exec();
      }
      @

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Abin
        wrote on last edited by
        #3

        Thanks Eddy...

        The old code was the automatically generated on project creation. On replacing with the above code , it works fine

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          Great!

          Happy coding

          Qt Certified Specialist
          www.edalsolutions.be

          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