[SOLVED] QtQuick-Plugin - get QmlViewer object



  • Hi guys,

    i wrote a QtQuick-Plugin in C++.
    One of my Classes should be possible to manipulate the QmlViewer.

    So... when an Object of my Class is created by the QmlViewer i want to get a pointer to the QmlViewer Object.
    Does anyone know a way to get the QmlViewer Object in a QtQuick-Plugin Class?

    Btw, using Qt 4.8.4 with Creator 2.5.2 on Windows.

    Mark



  • Hi Mark,

    In Qt4, QtQuick items are a subclass of QDeclarativeItem.

    QDeclarativeItem has a member function:

    @QGraphicsScene * QGraphicsItem::scene () const@

    which returns the scene your item is created in,

    Scene itself has a member function:

    @QList<QGraphicsView *> QGraphicsScene::views () const@

    which returns the views that are rendering the scene.

    your QmlViewer is probably a subclass of the first item in this QList ?



  • When I said QmlViewer I meant the Qt qmlviewer.exe.
    So you solved my problem.

    The thing is, is have an application which loads n instances of the qml viewer as an DLL.
    My QtQuick item has an static List which collects the pointers of all created elements of this type.
    And with the QGraphicsItem::scene () mehod I can find out, which elements are on the same qml viewer page. :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.