Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QGraphicsView vs QScrollArea for lots of primitive geometry rendering



  • I am trying to build a visualization tool to display a 2d navmesh (navigation mesh) for a game. This navmesh will contain thousands of triangles. The 2d map is likely too large to display in a single desktop application, so I will need to provide the ability to zoom in/out and scroll. I've implemented a version using the QGraphicsView and another using the QScrollArea (both contain a single custom QWidget which uses the paintEvent to draw all of the geometry). Which of these scrolling widgets is better for my use case? It seems like QGraphicsView has a lot of additional functionality that is not relevant for me, but also maybe it has some useful features that I'm not aware of?

    Here are some details about the drawing that are relevant:

    • I am drawing tens of thousands of points as circles (these are the vertices of the triangles)
    • I am drawing tens of thousands of straight lines (these are the edges of the triangles)
    • Sometimes I color an entire triangle, but not super often
      • That said, I am more often drawing triangles piece by piece (vertices and edges) rather than as a single polygon
    • It is feasible for me to break up the entire navmesh into blocks; the game data already reflects this
      • In this case, the entire 2d map would be split into something like 100-200 squares ("regions")
      • Its just a temporary design decision that I've decided to draw it all in one shot and not split it up
    • In the future, I also will draw secondary features on top of the navmesh
      • e.g. monsters' positions, players' positions, agents' planned paths, or areas that have some semantic meaning
    • In the future, I might want to underlay this navigation mesh with some images from the actual game's map

    Also, I've only just started reading about QOpenGlWidgets. Perhaps whichever I choose could benefit greatly from OpenGL? Any further reading on this topic would be very appreciated.

    Here is an image from the pathfinding library that I've developed while working on this. In this you can see one "region" of the map. I hope this gives a good idea of the kinds of things that I am drawing.
    Pathfinding Image