I would like to have my CentralWidget of a certain size. What do I need to do to change my main variable along the center widget? here's the code that doesn't work:
int main (int argc, char **argv) { QApplication app(argc, argv); QGLFormat glFormat; glFormat.setVersion(4,2); glFormat.setProfile( QGLFormat::CompatibilityProfile); QGLWidget* render_qglwidget = new MyWidget(glFormat); QGLContext* glContext = (QGLContext *) render_qglwidget->context(); glContext->makeCurrent(); QMainWindow* mainWindow = new MyMainWindow(); render_qglwidget->resize(720, 486); mainWindow->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); mainWindow->setCentralWidget(render_qglwidget); render_qglwidget->resize(720, 486); mainWindow->show(); return app.exec(); }
the window that opens will be very small.
I can set the size of the main window using
mainWindow->resize(720, 486);
and the central widget will also resize it. but the central widget will be slightly compressed, because the mainWindow toolbar also lies within these 486 pixels.
How to enable automatic resizing of mainWindow?
source share