[Qt-interest] How enforce aspect ratio of QGLWidget in QLayout?

Ed Sutton ESutton at fescorp.com
Fri Sep 10 15:24:43 CEST 2010


When main window is resized, I want to enforce the aspect ratio of video displayed in a QGLWidget.  My first attempt implemented this in GLWidget::resizeGL() by adjusting the glViewport width and height.  This sort of worked but left black bars at either the top or side and when I changed channels to a new aspect ration video, it would not fix itself because no resize called.

I think the correct approach must be to control the size of the GLWidget rather than the glViewport.  Do I need to implement this is the BorderLayout that the GLWidget was added to?

Thanks in advance for any tips or direction,

-Ed

/// Widget to handle reception of video and render as a OpenGl 2-D texture
class GLWidget : public QGLWidget
{
protected:
   // storage for one texture - the video frame bitmap
   GLuint m_texture[1];
   int m_width;
   int m_height;
   void initializeGL();
   void paintGL();
   void resizeGL(int width, int height);
};


// Border layout contains a channel selector to the right of the video window
class BorderLayout : public QLayout
{
};



More information about the Qt-interest-old mailing list