[Qt-interest] Making a Demo Movie

Nathan Carter nathancarter5 at gmail.com
Tue Jun 2 23:02:25 CEST 2009


You can ask a widget (including your whole window) to paint itself to  
an image.
	http://doc.qtsoftware.com/4.5/qwidget.html#render

Also, I've found Snapz Pro X on Mac OS X to be an excellent screen  
capture tool (though not free).  Makes very good movies, not choppy.

Nathan


On Jun 1, 2009, at 9:03 PM, Samuel Baxter wrote:

> I would like to record a video demonstrating an application such as
> the one attached.
>
> I have tried a screen grabbing utility (Screenium under Mac OSX), but
> the resulting movie is very choppy. Screenium is clearly congested
> writing to disk and can only grab one every several frames.
>
> Is there support in Qt for saving frames into main memory? One would
> write the outcome at a later point and then assemble the frames into
> an animation. How would you do it?
>
> Neither QGraphicsView nor QTimeLine seems relevant here.
> The actual application runs in 3D and so QGraphicsScene could not
> replace QGLWidget.
>
> Samuel
>
> ---------------- dump_screen_for_video/dump_screen_for_video.pro
> ----------------
> TEMPLATE = app
> TARGET =
> DEPENDPATH += .
> INCLUDEPATH += .
> QT        += opengl
>
> # Input
> HEADERS += screen_dumper.h
> SOURCES += main.cpp
>
> ---------------- dump_screen_for_video/main.cpp ----------------
> #include <QApplication>
> #include <iostream>
>
> #include "screen_dumper.h"
>
> int main(int argc, char *argv[])
> {
>    QApplication app(argc, argv);
>
>    if (!QGLFormat::hasOpenGL()) {
>        std::cerr << "This system has no OpenGL support" << std::endl;
>        return 1;
>    }
>
>    Screen_Dumper screen_dumper;
>    screen_dumper.setWindowTitle(QObject::tr("Screen Dumper"));
>    screen_dumper.resize(640, 480);
>    screen_dumper.show();
>
>    return app.exec();
> }
>
> ---------------- dump_screen_for_video/screen_dumper.h  
> ----------------
> #ifndef SCREEN_DUMPER_H
> #define SCREEN_DUMPER_H
> #include <QtGui>
> #include <QGLWidget>
> #include <QtGlobal>
> #include <QtCore/QDebug>
> const int TIMER_INTERVAL = 15;
>
> class Screen_Dumper : public QGLWidget
> {
>    Q_OBJECT
> public:
>    Screen_Dumper(QWidget *parent = 0) : QGLWidget(parent)
>    {
>        setFormat(QGLFormat(QGL::DoubleBuffer));
>        timer_number = startTimer(TIMER_INTERVAL);
>        qtime = QTime(0,0,0,0);
>    }
>    virtual ~Screen_Dumper() { killTimer(timer_number); }
> protected:
>    void timerEvent(QTimerEvent*) { updateGL(); }
>    void initializeGL() {
>        glDisable (GL_LIGHTING);
>        glClearColor (0.1, 0.2, 0.5, 1.0);
>        glColor3f(1.0, 1.0, 1.0);
>        glLineWidth(5.0);
>
>        glEnable (GL_LINE_SMOOTH);
>        glEnable (GL_BLEND);
>        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
>        glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
>    }
>
>    void resizeGL(int width, int height) {
>        glViewport (0, 0, (GLsizei) width, (GLsizei) height);
>        glMatrixMode (GL_PROJECTION);
>        glLoadIdentity();
>        glOrtho(-width/2.0, width/2.0, -height/2.0, height/2.0, -1.0,  
> 1.0);
>
>        glMatrixMode(GL_MODELVIEW);
>        glLoadIdentity();
>    }
>
>    void paintGL() {
>        glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
>        glPushMatrix();
>        glRotated(qtime.elapsed() / 30.0, 0.0, 0.0, 1.0);
>        glBegin(GL_LINES);
>        glVertex2d(0.0, 0.0);
>        glVertex2d(150.0, 0.0);
>        glEnd();
>        glPopMatrix();
>
>        glFlush ();
>    }
> private:
>    QTime qtime;
>    int timer_number;
> };
>
> #endif // SCREEN_DUMPER_H
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list