Embedded external window in QT does not refresh properly

I am developing a c++ application with QT (version 6.5.2) and I am using Open3D for some point cloud algorithms I’m working on. As such, I would like to visualize the pointcloud inside my application but, apparently (https://github.com/isl-org/Open3D/issues/1161), Open3D cannot be used as a widget.

A workaround i’ve tried is to generate a window displaying the pointcloud and then “encapsulate” it into a QWidget that is later added to the application, as shown in the code below:

open3d::visualization::DrawGeometries({ drawing_geom });//Actually done in a separate thread (see note)


std::this_thread::sleep_for(std::chrono::seconds(1)); //wait for window to be created

auto win = FindWindowExA(0, 0, nullptr, "Open3D");
auto window = QWindow::fromWinId((WId)win);
window->setFlags(Qt::FramelessWindowHint);
auto container = parent->createWindowContainer(window, Open3DVisualizationManager::getWidget());

parent->layout()->addWidget(container);

This code does work and it does indeed generate a window and then embed it inside the application, however there are some issues when it comes to refreshing: first, the visualizer is not displayed until the user clicks on it. Second, when the main window is resized, the visualizer does not update, leaving a “hole” until, once more, the user clicks on it. The screenshot at the bottom shows how, when resized, the area that the visualizer should be using is not updated and displays what was there before the application was resized (the foor red squares from the left)

I’ve tried adding update or repaint calls in the resize callbacks, but nothing worked. Does anyone have any suggestions on what the issue may be and how to solve it?
Thanks in advance.

Note: The open3D window is created using DrawGeometries in a separate thread rather than using the non-blocking Visualizer because I couldn’t get the latter to work (the window wouldn’t appear).

Screenshot

Leave a Comment