c++ - How to change QGLFormat for an existing QGLWidget at runtime? -


in application, user may change properties of opengl format (i.e. double buffering, multisampling, depth of various buffers, ...).

for now, there 1 qglwidget in application, , if user changes anything, destroy , recreate widget.

now, have more 1 widget. if format change, need destroy/recreate widgets. widget can assume various configurations, destroying/recreating them difficult. there way change format of qglwidget @ runtime?

alternatively, there way replace widget one? (i.e. destroy widget , place new 1 use stand)

this may work:

qglformat newformat; newformat.setdoublebuffer(true); // ... theglwidget->context().setformat(newformat); 

edit: can call qglwidget::setformat directly, it's obsolete , may not work. think it's safer recreate widget. here's how: put gl widget in sublayout (any kind - e.g. qvboxlayout) contains nothing gl widget. when want replace new gl widget, delete old one, , insert new widget in sublayout.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -