0
votes

This is related to my previous question Qt GLWidget in GraphicsScene for fast video display from image data (C++ , Windows)?.

I have been converting and showing video frames via a QPixMapItem in a QGraphicsScene / View, i.e. not with OpenGL. The conversion is causing a processor load that could be avoided by having said device drivers paint directly to a window, any scaling issues left aside for now.

While I was able to have the video shown to a standalone QWidget->winID() (QWidget, HWND, Qt::WA_NativeWindow, also see Using Qt with DirectX?) adding this widget to the scene does not result in video (it is not visible). Multiple inheritance from a QPixMapItem to be able to use QGraphicsScene::addItem() ("This scene takes ownership of the item.") did not help either.

Is the object losing its WId when it's becoming a child of the scene? Unfortunately, something else must be off, even when loading a QImage in the item's constructor, nothing is shown. I will have to investigate further.

Edit 1: The class inherited from QWidget and QGraphicsPixmapItem is able to display a pixmap, as tested with myWidget->setPixmap( QPixmap::fromImage( QImage("test.png") ) );. My previous image-loader simply was broken.

Showing the widget on top of the GraphicsView is going to be tricky, as scaling and off-view positions will have to be implemented but I doubt this will work glitch-free (and I think it is quite a bit of work).

1

1 Answers

1
votes

Displaying QWidget in QGraphicsScene is quite tricky. See QGraphicsProxyWidget description for more information. Basically, the widget you see in QGraphicsView is not real widget. QGraphicsView just redirects paint events to the underlying invisible QWidget. Apparently, Qt knows nothing about your video redirection, so it can't translate it to the scene.

I think you should not put your widget inside scene. Consider placing it above the graphics view, for example.