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. Qt Quick 2.0 how to publish viewer class to QML [ SOLVED ]
Forum Updated to NodeBB v4.3 + New Features

Qt Quick 2.0 how to publish viewer class to QML [ SOLVED ]

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.6k 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
    majster
    wrote on last edited by
    #1

    Hi!

    I'm developing desktop app using Qt Quick 2.0 and I need to be able to access viewer class through QML in order to hide/minimise application ( I'm building app with custom window decorations ).
    I fallowed this thread "[Link]":http://qt-project.org/forums/viewthread/3495 but no luck.

    This is my main.cpp:

    @
    #include <QtGui/QGuiApplication>
    #include "qtquick2applicationviewer.h"

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

    QtQuick2ApplicationViewer viewer;
    

    // viewer.rootContext()->setContextProperty("QmlApplicationViewer", (QObject *)&viewer);
    viewer.setFlags(Qt::FramelessWindowHint);
    viewer.setMainQmlFile(QStringLiteral("qml/ubusell/main.qml"));
    viewer.showExpanded();

    return app.exec&#40;&#41;;
    

    }

    @

    After I add this line to default main.cpp file:
    @
    viewer.rootContext()->setContextProperty("QmlApplicationViewer", (QObject *)&viewer);
    @

    I get this error:
    @
    In function 'int main(int, char**)':
    error: invalid use of incomplete type 'class QQmlContext'
    error: forward declaration of 'class QQmlContext'
    @

    Any ideas ?
    Thanks!

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Add this to your includes:
      @
      #include <QQmlContext>
      @

      (Z(:^

      1 Reply Last reply
      0
      • M Offline
        M Offline
        majster
        wrote on last edited by
        #3

        It works now, Thank you so much sierdzio!

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Pleasure. Happy further coding!

          (Z(:^

          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