0

The following code

QApplication a(argc, argv);
Phonon::MediaObject *media = new Phonon::MediaObject();
Phonon::VideoWidget *video = new Phonon::VideoWidget(NULL);
video->setGeometry(0, 0, 200, 200);
Phonon::createPath(media, video);
Phonon::MediaSource source("1.avi");
media->setCurrentSource(source);
media->play();
video->show();
return a.exec();

shows me a video. its ok. But this:

QApplication a(argc, argv);
QGraphicsScene scene;
Phonon::MediaObject *media = new Phonon::MediaObject();
Phonon::VideoWidget *video = new Phonon::VideoWidget(NULL);
video->setGeometry(0, 0, 200, 200);
Phonon::createPath(media, video);
Phonon::MediaSource source("1.avi");
media->setCurrentSource(source);
media->play();
QGraphicsProxyWidget * pWidget = scene.addWidget(video,Qt::Widget);
QGraphicsView view(&scene);
view.show();
return a.exec();

shows me a widget with a white background.. but where is my video ? ;) If i connect audiooutput to media, i hear sound of movie, so stream is going on. where is the mistake ? (Qt 4.7.0)

1 Answers1

0

Displaying QWidget in QGraphicsScene is quite tricky. See QGraphicsProxyWidget description for more information. Basically, the widget you see in QGraphicsView is not real widget. QGraphicsView just redirects paint events to the underlying invisible QWidget. It seems that video redirection is not supported here.

I think you should not put your widget inside scene. Consider placing it above the graphics view, for example.

Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127
  • Thanks for answer. Is there way to determinate that paint redirect is not supported ? And, if i can't do that on my platform, does it means that i can't over draw my video ? ;( I need draw playback buttons at the bottom of the video in full screen mode. I didnt find another way to do that, except using QGraphicsScene. – user2531802 Jun 28 '13 at 17:33
  • Try to add a child widget (button) to your video widget without layout and set its position with `move()`. See [this answer](http://stackoverflow.com/a/17341131/344347). – Pavel Strakhov Jun 28 '13 at 18:00
  • I tried your variant, but got something like this: https://docs.google.com/file/d/0B3K5B_5jQrkRYXBmSEk5S1VnNk0/edit?usp=sharing. Video starts from the offset 0 again, where i put a button. – user2531802 Jun 29 '13 at 01:53