Search code examples
c++qtqgraphicsviewjetson-xavier

Problem with QT QGraphicsView on Jetson Xavier


I am having a weird issue, and I'm not really sure where to start on figuring out the issue or even what to search for this. Hopefully someone will have seen this before and can help!

I have created a QT application in QTCreator/C++. I developed the app on a Ubuntu 20.04 machine which has QT version 5.12.8 (the default from apt). The application runs and behaves as expected on my development machine.

For deployment, we are running the application on a Jetson Xavier, which is an ARM machine. It is running Ubuntu 18.04 which has QT version 5.9.5 installed (also the default for the OS). When I run the application there, everything works fine apart from one QGraphicsView, which shows a blank white screen instead of the intended display.

GraphicsView A works, it shows a QPixMap on a Graphics Scene. GraphicsView B displays only white, it is supposed to show a series of points and lines on a black background (displayed in vector form as QObjects). Again this works fine on my machine.

The difference between these two QGraphicsViews is that the one that doesn't work has a number of mouse input event functions enabled so you can pan and zoom the QGraphicsScene. I have discovered that if I comment out the following three lines in my QGraphicsView B setup, then I can see the points and lines again:

    m_graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
    m_graphicsView->viewport()->installEventFilter(this);
    m_graphicsView->setMouseTracking(true);

The event filter handles scroll wheel events for zooming. It seems like any one of these three lines disables the view, I've tried several combinations of some commented out or not. Obviously when I remove these I can no longer pan/zoom the QGrapicsScene, which I need to able to do.

I can't figure out why these functions might be affecting the QGraphicsView showing on the Jetson. I did find that the QMenu at the top of the application didn't work on the Jetson at first until I disabled the 'NativeMenuBar' attribute (presumably forcing a QT thing instead of native). I had a look through QGraphicsView and mouse things for something like this and came up blank.


Solution

  • This isn't a strict answer, but I eventually found a workaround that mitigates this issue.

    After a bit more investigation I found the problem to be specifically related to the Event Filter, and 'installEventFilter'. I'm not sure what the problem is still.

    The workaround I found was rather than using an event filter, I sub classed the QGraphicsView and handled the mouse events with customised versions of QGraphicsView::mouseReleaseEvent etc.