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] Error: forward declaration of 'class QQmlContext'
Forum Updated to NodeBB v4.3 + New Features

[Solved] Error: forward declaration of 'class QQmlContext'

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 18.7k 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.
  • M Offline
    M Offline
    maksim1979
    wrote on 29 Jul 2013, 10:20 last edited by
    #1

    Hi guys

    I'm playing with QML/C++ integration and now I'm trying to set context property as described here http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-contextproperties.html

    So my code looks like this
    @
    #include <QtGui/QGuiApplication>
    #include "qtquick2applicationviewer.h"
    #include <QDateTime>

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    viewer.rootContext()->setContextProperty(QStringLiteral("somedata"), QDateTime::currentDateTime());
    viewer.setMainQmlFile&#40;QStringLiteral("qml/TestQML/main.qml"&#41;&#41;;
    viewer.showExpanded();
    
    return app.exec&#40;&#41;;
    

    }@

    I've just added line 10 to the project generated code
    @viewer.rootContext()->setContextProperty(QStringLiteral("somedata"), QDateTime::currentDateTime());@

    But unfortunately I've got this error
    ../TestQML/main.cpp:10:25: error: invalid use of incomplete type 'class QQmlContext'
    In file included from ../Qt5.1.0/5.1.0/gcc/include/QtQuick/QQuickView:1:0,
    from ../TestQML/qtquick2applicationviewer/qtquick2applicationviewer.h:14,
    from ../TestQML/main.cpp:2:
    ../Qt5.1.0/5.1.0/gcc/include/QtQuick/qquickview.h:52:7: error: forward declaration of 'class QQmlContext'

    Maybe someone came across with that before?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 29 Jul 2013, 10:30 last edited by
      #2

      Hi,

      You seem to be missing:

      @#include <QQmlContext>@

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • M Offline
        M Offline
        maksim1979
        wrote on 29 Jul 2013, 11:01 last edited by
        #3

        SGaist, thank you very very much. Last 10 years I spent with java and now I'm having a lot of fun with such stupid mistakes. Thank you for you time and have a nice day

        1 Reply Last reply
        1
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 29 Jul 2013, 11:07 last edited by
          #4

          You're welcome ! A little learning curve... Happy coding :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          1/4

          29 Jul 2013, 10:20

          • Login

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