[Qt-qml] Placing QGraphicsScene within a QML UI?
Eduardo Fleury
eduardo.fleury at openbossa.org
Wed Nov 3 18:47:53 CET 2010
Hi Michael,
Well, the QML scene is a QGraphicsScene in fact. So basically what you are
trying to do is to add a QGraphicsView (with its scene) inside another
scene.
In theory you could wrap your QGraphicsView inside a QGraphicsProxyWidget,
that done, you can add this "standard" QGraphicsWidget to the QML scene, by
either:
1) inspecting the QML scene from C++ and hooking your special item under an
item there, or
2) registering your type to the QML world (qmlRegisterType) and
instanciating your item from QML side.
I usually think that using QProxyWidgets is a suboptimal situation,
specially if you're adding a full fledged graphics view inside it. Sounds
like mouse events and everything else will have do travel a lot before
getting to the right guy, feels like a little fragile to me. But should
work.
Another idea is to try to add some of the QGraphicsWidgets you already have
right into the original QML scene. That would make you deal with only one
scene, not two, and also avoid dealing with proxies... sounds better to me.
Maybe if you create a wrapper QGraphicsItem to hold all your animated data
display inside it.
Best,
Eduardo
On Wed, Nov 3, 2010 at 10:23 AM, Michael Rychlik
<michael.rychlik at gmail.com>wrote:
> 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?
>
>
>
> _______________________________________________
> Qt-qml mailing list
> Qt-qml at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-qml
>
>
--
Eduardo M. Fleury
OpenBossa - INdT
http://eduardofleury.com/
http://www.openbossa.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20101103/a1cc5152/attachment.html
More information about the Qt-qml
mailing list