How to add items inherited from QGraphicsItem?

151
1
Jump to solution
05-02-2021 06:26 AM
FatmaAkdemir
New Contributor III

We have migrated from QGraphicsView to 3d Scene with a basemap. We have plenty of item classes which have paint() functions (inheriting QGraphicsItem). Is there any way to add these items to Scene? Do we have to rewrite all these classes by changing the base class as "Graphics" instead of "QGraphicsItem"?

0 Kudos
1 Solution

Accepted Solutions
JamesBallard1
Esri Contributor

@FatmaAkdemir ,

 There is some overloaded language between the ArcGIS Runtime classes and The Qt Company's classes.

When working with the ArcGIS Runtime, we recommend that if you are able, to use the Runtime classes as much as possible. You won't need to call paint() manually when you are working with the Esri Graphic class as we handle the entire rendering pipeline for you.

That being said, if you need to integrate existing QGraphicsItem objects into the view, you might be able to subclass our existing 3D SceneGraphicsView (our 3D Widgets class that inherits QGraphicsView) and add items that way, although you'd need to carefully convert screen coordinates into geographic coordinates to get them to appear correctly with the Runtime objects, and you would not be able to select/interact them as those objects would not be known to the Runtime SDK.

I highly recommend using the Runtime's Graphic class to visualize your symbology if possible. You will be able to interact with, symbolize and so much more within the Runtime SDK capabilities.

View solution in original post

1 Reply
JamesBallard1
Esri Contributor

@FatmaAkdemir ,

 There is some overloaded language between the ArcGIS Runtime classes and The Qt Company's classes.

When working with the ArcGIS Runtime, we recommend that if you are able, to use the Runtime classes as much as possible. You won't need to call paint() manually when you are working with the Esri Graphic class as we handle the entire rendering pipeline for you.

That being said, if you need to integrate existing QGraphicsItem objects into the view, you might be able to subclass our existing 3D SceneGraphicsView (our 3D Widgets class that inherits QGraphicsView) and add items that way, although you'd need to carefully convert screen coordinates into geographic coordinates to get them to appear correctly with the Runtime objects, and you would not be able to select/interact them as those objects would not be known to the Runtime SDK.

I highly recommend using the Runtime's Graphic class to visualize your symbology if possible. You will be able to interact with, symbolize and so much more within the Runtime SDK capabilities.

View solution in original post