Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. The strange passed value in resizeGL(int w, int h) each time I resize the window
Forum Updated to NodeBB v4.3 + New Features

The strange passed value in resizeGL(int w, int h) each time I resize the window

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 217 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yixun
    wrote on last edited by Chris Kawa
    #1

    Hi,
    On Windows10, I implement a MyOpenGLWidet class by inheriting QOpenGLWidget and overwrite the void resizeGL(int w, int h) method.

    The code snippet is as follows:

    class OGLWidget : 
    public QOpenGLWidget,
    public QOpenGLFunctions
    {
      Q_OBJECT
      public:   
      OGLWidget();
      ~OGLWidget() {};
      resizeGL();
    }
    
    void OGLWidget::resizeGL(int width, int height)
    {
       //The output width and height are not correct, very small than 
       //actual sizes
       qDebug() << "The resized width and height is: " << width << ", " 
       << height;
    
       m_width = width;
       m_height = height;
    }
    
    //add the widget
    m_planningView = new OGLWidget();       
    QSurfaceFormat format;
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setVersion(3, 3);
    format.setSamples(4);
    
    m_planningView->setFormat(format);
    QGridLayout *preOperationLayout = new QGridLayout();    
    preOperationLayout->addWidget(m_planningView, 0, 0);
    
    m_preOperationFrame = new QFrame();
    m_preOperationFrame->setFrameStyle(QFrame::Box | QFrame::Raised);
    m_preOperationFrame->setLayout(preOperationLayout);
    

    However, each time as I resize the parent window, I found the passed value of w and h are not correct. The passed value are very small compared with the real size.

    Many thanks.
    YL

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Yixun said in The strange passed value in resizeGL(int w, int h) each time I resize the window:

      void OGLWidget::resizeGL(int width, int height)
      {
      //The output width and height are not correct, very small than
      //actual sizes
      m_width = width;
      m_height = height;
      }

      You're missing to call to the base class.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • Y Offline
        Y Offline
        Yixun
        wrote on last edited by
        #3

        I output the size at the beginning of method resizeGL(), so I think it is not related to the calling the base.
        I found the reason is the setting of the display. If I set the display with 3840x2160., the output of QScreen is actually 1280x720. If I set the display to 1920x1080 and the output of QScreen is the same and then the resizeGL works.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved