Adding a QGraphicsView to a QGraphicsItem?



  • Hello -

    Is adding a QtGraphicsView object to a QGraphicsItem object difficult? I can't seem to Google an example.

    I ask because in QML (almost?) everything is a QGraphicsItem. We have legacy Qt code that uses a QGraphicsView to show a QGraphicsScene containing QGraphicsItems. Therefore I would like to add the QtGraphicsView to a pre-existing QML QGraphicsItem like "Rectangle" or "Item".

    Maybe the other solution is to expose a QGrpahicsView into QML using qmlRegisterType<>, but I can't seem to find a good example of that either.

    I know that the proper thing to do is port the QtGraphicsView functionality into a QML-only solution. My goal is that adding a QtGraphicsView object to a QGraphicsItem would be an interim step. I don't think there will be a major efficiency issue because the number of QGraphicItem objects should not exceed the very low tens. In addition, we are predicting situations where emergent requirements may require this solution.

    Thank You,

    cfg83



  • Why would you want to do that? I mean you can add items inside of other items and the view handles it as you would expect. Just like you can add a widget inside of a widget.

    Also in Qt5 QML is no longer using the QGV/I/S stack.



  • utcenter -

    [quote author="utcenter" date="1359568376"]Why would you want to do that? I mean you can add items inside of other items and the view handles it as you would expect. Just like you can add a widget inside of a widget.

    Also in Qt5 QML is no longer using the QGV/I/S stack.[/quote]

    As stated, it's only an interim step to demonstrate functionality on the way to full QML.

    Also, we are on Qt 4.8.x . For embedded development we are evaluating the Yocto project, which appears to support 4.8.1 and 4.8.3 as of December 7th, 2012. I just asked IRC:#yocto and the Qt version as of today is 4.8.4 .

    cfg83



  • Create a widget with a graphics view inside and wrap the widget in a QGraphicsProxyWidget.



  • What about finding all the graphicsitems that are in your embedded view and adding those to your scene instead. Add a rectangle that clips to hold them all together...


Log in to reply
 

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