After trying lots and lots of variants...
Here's the acceptable solution. The code is crude but I think it can help those who have similar problems.
main.cpp
#include "customproxy.h"
#include <phonon/mediaobject.h>
#include <phonon/mediasource.h>
#include <phonon/videowidget.h>
#include <QtGui>
#include <QtDebug>
#include <QAbstractFileEngine>
#ifndef QT_NO_OPENGL
#include <QGLWidget>
#endif
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(videowall);
Phonon::MediaObject *media = new Phonon::MediaObject();
Phonon::VideoWidget *video = new Phonon::VideoWidget();
CustomProxy *proxy = new CustomProxy(0, 0);
Phonon::createPath(media, video);
proxy->setWidget(video);
QRectF rect
= proxy
->boundingRect
();
proxy->setPos(0, 0);
proxy->show();
scene.addItem(proxy);
media
->setCurrentSource
(QString("output22.avi"));
media->play();
titem->setPos(rect.width()/2, rect.height()/2);
#ifndef QT_NO_OPENGL
#endif
view.
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
view.show();
view.setWindowTitle("Eternal fire");
// view.showFullScreen();
return app.exec();
}
#include "customproxy.h"
#include <phonon/mediaobject.h>
#include <phonon/mediasource.h>
#include <phonon/videowidget.h>
#include <QtGui>
#include <QtDebug>
#include <QAbstractFileEngine>
#ifndef QT_NO_OPENGL
#include <QGLWidget>
#endif
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(videowall);
QApplication app(argc, argv);
QGraphicsScene scene;
Phonon::MediaObject *media = new Phonon::MediaObject();
Phonon::VideoWidget *video = new Phonon::VideoWidget();
CustomProxy *proxy = new CustomProxy(0, 0);
Phonon::createPath(media, video);
proxy->setWidget(video);
QRectF rect = proxy->boundingRect();
proxy->setPos(0, 0);
proxy->show();
scene.addItem(proxy);
media->setCurrentSource(QString("output22.avi"));
media->play();
QGraphicsTextItem *titem = scene.addText("Bla-bla-bla");
titem->setPos(rect.width()/2, rect.height()/2);
QGraphicsView view(&scene);
#ifndef QT_NO_OPENGL
view.setViewport(new QGLWidget);
#endif
view.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
view.show();
view.setWindowTitle("Eternal fire");
// view.showFullScreen();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
customproxy.h
#ifndef CUSTOMPROXY_H
#define CUSTOMPROXY_H
#include <QGraphicsProxyWidget>
class CustomProxy : public QGraphicsProxyWidget
{
Q_OBJECT
public:
CustomProxy
(QGraphicsItem *parent
= 0, Qt
::WindowFlags wFlags
= 0);
protected:
void resizeEvent(QGraphicsSceneResizeEvent *event);
private slots:
private:
};
#endif
#ifndef CUSTOMPROXY_H
#define CUSTOMPROXY_H
#include <QGraphicsProxyWidget>
class CustomProxy : public QGraphicsProxyWidget
{
Q_OBJECT
public:
CustomProxy(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
QRectF boundingRect() const;
protected:
void resizeEvent(QGraphicsSceneResizeEvent *event);
private slots:
private:
};
#endif
To copy to clipboard, switch view to plain text mode
customproxy.cpp
#include "customproxy.h"
#include <QtGui>
CustomProxy
::CustomProxy(QGraphicsItem *parent, Qt
::WindowFlags wFlags
) : QGraphicsProxyWidget(parent, wFlags)
{
setCacheMode(NoCache);
}
QRectF CustomProxy
::boundingRect() const {
return QGraphicsProxyWidget::boundingRect().adjusted(0, 0, 0, 0);
}
void CustomProxy::resizeEvent(QGraphicsSceneResizeEvent *event)
{
//
}
#include "customproxy.h"
#include <QtGui>
CustomProxy::CustomProxy(QGraphicsItem *parent, Qt::WindowFlags wFlags)
: QGraphicsProxyWidget(parent, wFlags)
{
setCacheMode(NoCache);
}
QRectF CustomProxy::boundingRect() const
{
return QGraphicsProxyWidget::boundingRect().adjusted(0, 0, 0, 0);
}
void CustomProxy::resizeEvent(QGraphicsSceneResizeEvent *event)
{
//
}
To copy to clipboard, switch view to plain text mode
Use wisely, live long and prosper =)
Special thanks to this article http://labs.qt.nokia.com/2008/11/28/videos-get-pimped/
Also I've tried combining ffmpeg + sdl but unfortunately got stuck with SDL_Surface not willing to attach itself to QWidget. But that's another story)
Bookmarks