Jul 14

QtScreenGrabber – Recording your QtWidgets

It turns out recording your Qt screen/widget from your Qt code as a video is quite tricky.

I created the QtScreenGrabber for making this process faster and easier. It makes it this easy to record your widget and output to a video file:

ScreenGrabber *grabber = new ScreenGrabber;
grabber->setup(QString("output.mpg"), width, height);
grabber->startRecording(20); // record for 20 seconds

It is based on ofxFFMPEGVideoWriter (developed by Roy Shil)  and one of the Qt examples (Animated Tiles).

You can find the full example here on GitHub:


This is for capturing your widget as a video, but if you need to save the screen once in a while there is an example for that distributed with Qt examples.