Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 使用Docker使用QOffscreenSurface进行屏幕外渲染_Qt_Opengl_Rendering_Pybind11 - Fatal编程技术网

Qt 使用Docker使用QOffscreenSurface进行屏幕外渲染

Qt 使用Docker使用QOffscreenSurface进行屏幕外渲染,qt,opengl,rendering,pybind11,Qt,Opengl,Rendering,Pybind11,我使用Qt5进行屏幕外渲染,在Docker内部运行时出现分段错误 我将代码放在c++中,并通过python使用pybind11 这是导致SEG故障的代码 QSurfaceFormat glFormat; glFormat.setVersion(3, 3); glFormat.setProfile(QSurfaceFormat::CoreProfile); glFormat.setRenderableType(QSurfaceFormat::OpenGL); surface = new QOff

我使用Qt5进行屏幕外渲染,在Docker内部运行时出现分段错误

我将代码放在
c++
中,并通过
python
使用
pybind11

这是导致SEG故障的代码

QSurfaceFormat glFormat;
glFormat.setVersion(3, 3);
glFormat.setProfile(QSurfaceFormat::CoreProfile);
glFormat.setRenderableType(QSurfaceFormat::OpenGL);

surface = new QOffscreenSurface();
surface->setFormat(glFormat);
surface->create(); // <-- Here 
我试图通过
xvfb run-a python prg.py
运行它,但得到了相同的错误

有调试这个的指针吗


关于这个问题,如果我在
QApplication
中包装的主线程中使用上面的代码,那么上面的代码可以很好地工作。只有当我将其移动到函数中以便在python中调用时,才会出现此问题

关于在主线程之外运行的最后一条线索可能是您遇到的问题

查看文档:

注意:由于QOffscreenSurface由上的QWindow支持 某些平台、跨平台应用程序必须确保创建() 仅在主(GUI)线程上调用。QOffscreenSurface就是这样 可以在其他线程上安全地与makeCurrent()一起使用,但 初始化和销毁必须始终在主(GUI)上进行 线


因此,解决方案可能是在主线程中创建曲面,然后通过pybind11按需要使用它。

提供一个我没有GUI线程。有没有关于如何使用pybind11调用创建该线程的指针?GUI线程只是应用程序的主线程。你应该在那里创建你的表面,然后如果你想从另一个线程使用它,调用
boolqopenglcontext::makeCurrent(QSurface*surface)
。但是当使用pybind时,我只需要链接一个函数调用,例如,在python
import myPackage as p.myFunction()中
在调用surface之前,我在pybind函数中调用了QApplication,并使用xvfb运行它以使ti工作。
QObject::connect: Cannot connect (null)::destroyed(QObject*) to QOffscreenSurface::screenDestroyed(QObject*)