Jetson nano: Black window when using openCV named window with OpenGL

I am using JetPack 4.4.1 on Jetson Nano.
OpenCV 4.5.1 was built from source with CUDA and OpenGL support
(patch was applied to cuda_gl_interop.h. Not sure, whether it is still required, but I think it can’t hurt).

cv::getBuildInformation reports openGL support present with correct path to the .so libraries.

In c++ program, I am using opencv named window:
cv::namedWindow (m_name, cv::WINDOW_KEEPRATIO | v::WINDOW_OPENGL);
along with cv::imshow

The output window keeps black!
(Also tried different settings, window and full screen, and different openCV versions - nothing helps)

No errors are reported. Just black output.
Imshow works when not using the WINDOW_OPENGL flag.
OpenGL seems to be ok: Gstreamer glimagesink produces correct output.

Any help appreciated!

A user has shared a solution. Please try
Black images with Qt5 and OpenGL - #7 by dominik.zebec

I have had this working for displaying a GpuMat only with GTK2 backend, not Qt.

Setting WITH_QT=4 solved the issue.

Setting WITH_QT=OFF, works also, if WITH_GTK=ON, WITH_GTK_X_2=ON is used.
Using WINDOW_OPENGL for openCV named window greatly improved performance and quality of video output.

Thank you for your help.