Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Size of the child widget is always fixed in MainWindow constructor.



  • Hi.

    I have this setup in UI designer

    designer setup

    And I'm trying to get the size of the OpenGLWidget in MainWindow contructor but I always get the fixed size of a very small window (100,30) instead of a normal size of my widget. Even when the first auto resize event happens the widget size is still the same.

    Only when I manually resize the window, does the size change to the normal size e.g. (900,600)

    How do I get the proper size of my widget control when I start the program?

    Thanks.



  • @Simula
    I don't know anything specific about "OpenGLWidget", but in Qt you don't get widget sizes during constructors. I don't know when your "first auto resize event happens". In general, you have to wait for showEvent() to get any reliable idea of widget sizes, as that's when everything sizes/readjusts.



  • Thanks, that was it.


Log in to reply