Hi,

I have a strange problem with my qt application. I have a custom QGLWidget which get a stream video from a camera. Like this:
sans.jpg

Ans as soon i put an other widget in an other layout, my custom widget stop rendering. Like this:
avec.png

And i got the error :
Qt Code:
  1. QOpenGLContext::swapBuffers() called with non-exposed window, behaviour is undefined.
To copy to clipboard, switch view to plain text mode 

Here is the code of my custom widget:
Qt Code:
  1. #include "widget.h"
  2. #include "ui_widget.h"
  3.  
  4. Widget::Widget(QWidget *parent) :
  5. QGLWidget(parent),
  6. ui(new Ui::Widget)
  7. {
  8. ui->setupUi(this);
  9. }
  10.  
  11. Widget::~Widget()
  12. {
  13. wglMakeCurrent(GetDC((HWND)this->winId()), this->contextGL);
  14. cu.ClearProcess(nvGl.m_videoBuffer);
  15. nvGl.cleanupVideo(GetDC((HWND)this->winId()));
  16. delete ui;
  17. }
  18.  
  19. void Widget::initializeGL(){
  20. glewInit();
  21. rec = Recorder();
  22. this->contextGL =wglGetCurrentContext();
  23. nvC = NVConfig();
  24. nvC.GlobalInit();
  25. nvGl = NVGL(nvC.l_vioConfig,GetDC((HWND)this->winId()));
  26. cu= CUGL();
  27. cu.InitProcess(nvGl.m_videoBuffer);
  28. QTimer::singleShot(16,this,SLOT(Tick()));
  29. }
  30.  
  31. void Widget::resizeGL(int w, int h){
  32. this->resize(w,h);
  33. if(h==0)
  34. h =1;
  35. glViewport(0,0,w,h);
  36. glMatrixMode(GL_PROJECTION);
  37. glLoadIdentity();
  38. perspectiveGL(45.0f,w/h,0.1f,100.0f);
  39. glMatrixMode(GL_MODELVIEW);
  40. glLoadIdentity();
  41.  
  42. }
  43. void Widget::Tick(){
  44. nvC.DetectIStatus();
  45. nvC.setCaptureDevice();
  46. nvGl.StartCapture();
  47. cu.ProcessVideo(nvGl.m_videoBuffer);
  48. rec.RecordShot(nvGl.m_videoTexture);
  49. paintGL();
  50.  
  51. QTimer::singleShot(16,this,SLOT(Tick()));
  52. }
  53.  
  54. void Widget::paintGL(){
  55. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  56.  
  57. glLoadIdentity();
  58. glTranslatef(-0.5f,-.5f,-1.1f);
  59. glBegin(GL_QUADS);
  60. glTexCoord2f(0,0);
  61. glVertex3f(0,0,0);
  62. glTexCoord2f(0,1.0f);
  63. glVertex3f(0,1.0f,0);
  64. glTexCoord2f(1.0f,1.0f);
  65. glVertex3f(1.0f,1.0f,0);
  66. glTexCoord2f(1.0f,0);
  67. glVertex3f(1.0f,0,0);
  68. glEnd();
  69. }
  70. void Widget::Record(){
  71. rec.Start_StopRecord(nvGl.m_videoTexture);
  72. }
  73.  
  74.  
  75. void Widget::perspectiveGL(GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar){
  76. const GLdouble pi = 3.1415926535897932384626433832795;
  77. GLdouble fW, fH;
  78. fH = tan( fovY / 360 * pi) * zNear;
  79. fW = fH * aspect;
  80. glFrustum( -fW,fW,-fH,fH,zNear,zFar);
  81. }
To copy to clipboard, switch view to plain text mode 

If you have any idea.
thanks in advance