Qt5 allows to use QSurfaceFormat::setSwapInterval
which lets the application to decide whether to enable VSync or not. However, this can only be done when the application is started, e.g. to disable VSync it's sufficient to call the following before the application object is created:
QSurfaceFormat format;
format.setSwapInterval(0);
QSurfaceFormat::setDefaultFormat(format);
The code above will disable VSync in a Qt Quick application by setting the swap interval to zero in the Opengl context used by the Qt Scenegraph. However, what I would like is the possibility to disable and enable VSync at runtime whenever required (not just before the start of the QML engine), something like this:
void toggleVSync(){...}
Looking around I didn't really find anything, so I was wondering if there was a way to achieve this.