Hi Ian,

Den 19-05-2012 14:49, Ian Geiser skrev:
> Greetings, I have some C++ QGraphics View code that I would like to
> move to QML.  The binding was trivial to make the Graphics Items into
> plugins, but where I get stuck is that I have a model that manages
> the lifetimes of the items.  I am confused as to has to expose this
> model to QML.  I can place my items on the canvas in the QML, and I
> can return the QObject pointers from the model.  What I cannot seem
> to do is place the QGraphicsView items onto the canvas from that
> point. Any hints?  Thanks!

You need to convert the classes to QDeclarativeItem subclasses.

After doing this, I think the only issue you will have is to find the 
proper parent for your items. Things don't turn up in QML unless they 
have a parent.

There is a good amount of information on this page:

http://qt-project.org/doc/qt-4.8/qtbinding.html

Adding items dynamically using C++ is still awkward. But it is possible, 
I have done it one several customer projects now.

It's funny that QML is always described as a language for dynamic UIs, 
when in fact it's specifically designed for static UIs where the items 
can move.

Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
_______________________________________________
Qt-qml mailing list
Qt-qml@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to