I am trying to design an application to play multiple video (media) files and allow user modification capability on each one (eg, scaling, rotating, inverting etc of videos). I started by studying Phonon, but after going into it for a while read that it is no longer supported (or its support is doubtful) in >= Qt5. So then i went back and now i'm looking at qtmultimedia - QMediaPlayer. I'm stuck and confused on what widgets i must use. QMediaPlayer can show its output (video) on QVideoWidget, QGraphicsVideoItem and QAbstractVideoSurface. Since I need the capabilities of rotation etc, i believe i must incorporate QGraphicsScene/View.

<1> So what should the approach be? I did this: used QVideoWidget -> added this to QGraphicsProxyWidget via its setWidget() (though setWidget() takes QWidget* and QVideoWidget is not derived from QWidget as i see in Qt Assistant -- why is this allowed btw?) -> Added this QGraphicProxyWidget to QGraphicsScene via addItem() -> added this QGraphicsScene to QGraphicsView while constructing it -> added QGraphicsView to QMainWindow via setCentralWidget(). Is this fine? When to use QGraphicsVideoItem and QAbstractVideoSurface?

<2> When adding multiple QVideoWidget in the following manner i don't see any video or the QVideoWidget itself (i've painted to distinguish it). What am i doing wrong? (there is audio output though):

Qt Code:
  1. QVideoWidget *pVideoWidget1 = new QVideoWidget(0);
  2. pVideoWidget1->setPalette(QPalette(QColor(255,0,0),QColor(0,255,0)));
  3. QVideoWidget *pVideoWidget2 = new QVideoWidget(0);
  4. pVideoWidget2->setPalette(QPalette(QColor(255,0,0),QColor(0,0,255)));
  5.  
  6. m_pMediaPlayer1 = new QMediaPlayer(this);
  7. m_pMediaPlayer2 = new QMediaPlayer(this);
  8. m_pMediaPlayer1->setVideoOutput(pVideoWidget1);
  9. m_pMediaPlayer2->setVideoOutput(pVideoWidget2);
  10.  
  11. m_pCustomGraphicsProxy1 = new CustomGraphicsProxy(0); //this is just a class derived from QGraphicsProxyWidget to implement drag and drop of videos
  12. m_pCustomGraphicsProxy2 = new CustomGraphicsProxy(0);
  13. m_pCustomGraphicsProxy1->setWidget(pVideoWidget1);
  14. m_pCustomGraphicsProxy2->setWidget(pVideoWidget2);
  15.  
  16. QGraphicsScene *pGraphicsScene = new QGraphicsScene(this);
  17. QGraphicsLinearLayout *pGraphicsLinearLayout = new QGraphicsLinearLayout;
  18.  
  19. CustomGraphicsProxy* button = new CustomGraphicsProxy(0);
  20. button->setWidget(new QPushButton); //this i can see
  21. CustomGraphicsProxy* button1 = new CustomGraphicsProxy(0);
  22. button1->setWidget(new QPushButton); //this i can see too
  23.  
  24. pGraphicsLinearLayout->addItem(button);
  25. pGraphicsLinearLayout->addItem(m_pCustomGraphicsProxy1); //can't see
  26. pGraphicsLinearLayout->addItem(m_pCustomGraphicsProxy2); //can't see
  27. pGraphicsLinearLayout->addItem(button1);
  28.  
  29.  
  30. CustomGraphicsProxy *temp = new CustomGraphicsProxy(0);
  31. temp->setLayout(pGraphicsLinearLayout);
  32. pGraphicsScene->addItem(temp);
  33. temp->show();
  34.  
  35. m_pGraphicsView = new QGraphicsView(pGraphicsScene, this);
  36.  
  37. setCentralWidget(m_pGraphicsView);
  38.  
  39. QObject::connect(m_pCustomGraphicsProxy1, SIGNAL(sigNewFileDragDropped()), this, SLOT(sloPlayOnWindow1()));
  40. QObject::connect(m_pCustomGraphicsProxy2, SIGNAL(sigNewFileDragDropped()), this, SLOT(sloPlayOnWindow2()));
  41.  
  42. //just for testing - this gives only audio no video can be seen
  43. m_pMediaPlayer1->setMedia(QUrl::fromLocalFile("d:/z.avi"));
  44. m_pMediaPlayer1->play();
To copy to clipboard, switch view to plain text mode 

<3> Before i study this further, am i choosing the right tools in Qt to manipulate videos as i mentioned before or something else needs to be done?