[Qt-qml] Placing QGraphicsScene within a QML UI?
alan.alpert at nokia.com
alan.alpert at nokia.com
Thu Nov 4 03:09:02 CET 2010
>From: qt-qml-bounces at trolltech.com [mailto:qt-qml-bounces at trolltech.com] On Behalf Of ext Michael Rychlik
>Sent: Wednesday, November 03, 2010 11:24 PM
>To: qt-qml at trolltech.com
>Subject: [Qt-qml] Placing QGraphicsScene within a QML UI?
>
>I have an application the main feature of which is a QGraphicsScene/QGraphicsView used for an animated data display.
>This view sits in a tab and the app. has the usual menus/buttons/dialogs etc.
>
>Having discovered QML I'd quite like have ago at rebuilding the apps user interface with it. That is, to be able to drop my graphics scene into a component that QML could >then display.
>
>I've waded through the docs. enough to know how to make a C++ data model usable form QML and how to create a graphic drawn in C++ for use in QML. (pie char example at >least)
>
>Does anyone have any clues or pointers as to how to drop an entire graphics scene into a QML component?
The two options that come to my mind are
1) Make the QGraphicsItems into QGraphicsObjects and expose them to QML. Then you don't actually place the entire graphics scene in the QML component, but you can reuse all the QGraphicsItem code that you wrote to get them to do what you want, and then easily recreate the scene with QML.
2) As QML components just create QGraphicsObjects and place them into a QGraphicsScene, it would be easier to just place QML Components into the existing graphics scene. You can create the QML components using QDeclarativeComponent instead of QDeclarativeView, and just add them to the existing QGraphicsView. In your case, this would involve expanding the QGraphicsView and managing the items more carefully (since the existing items are not always visible).
--
Alan Alpert
More information about the Qt-qml
mailing list