PDA

View Full Version : What Qt GUI Containers to use? Also Related Video Display issue - Windows 7



ustulation
30th December 2012, 17:19
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):


QVideoWidget *pVideoWidget1 = new QVideoWidget(0);
pVideoWidget1->setPalette(QPalette(QColor(255,0,0),QColor(0,255,0 )));
QVideoWidget *pVideoWidget2 = new QVideoWidget(0);
pVideoWidget2->setPalette(QPalette(QColor(255,0,0),QColor(0,0,255 )));

m_pMediaPlayer1 = new QMediaPlayer(this);
m_pMediaPlayer2 = new QMediaPlayer(this);
m_pMediaPlayer1->setVideoOutput(pVideoWidget1);
m_pMediaPlayer2->setVideoOutput(pVideoWidget2);

m_pCustomGraphicsProxy1 = new CustomGraphicsProxy(0); //this is just a class derived from QGraphicsProxyWidget to implement drag and drop of videos
m_pCustomGraphicsProxy2 = new CustomGraphicsProxy(0);
m_pCustomGraphicsProxy1->setWidget(pVideoWidget1);
m_pCustomGraphicsProxy2->setWidget(pVideoWidget2);

QGraphicsScene *pGraphicsScene = new QGraphicsScene(this);
QGraphicsLinearLayout *pGraphicsLinearLayout = new QGraphicsLinearLayout;

CustomGraphicsProxy* button = new CustomGraphicsProxy(0);
button->setWidget(new QPushButton); //this i can see
CustomGraphicsProxy* button1 = new CustomGraphicsProxy(0);
button1->setWidget(new QPushButton); //this i can see too

pGraphicsLinearLayout->addItem(button);
pGraphicsLinearLayout->addItem(m_pCustomGraphicsProxy1); //can't see
pGraphicsLinearLayout->addItem(m_pCustomGraphicsProxy2); //can't see
pGraphicsLinearLayout->addItem(button1);


CustomGraphicsProxy *temp = new CustomGraphicsProxy(0);
temp->setLayout(pGraphicsLinearLayout);
pGraphicsScene->addItem(temp);
temp->show();

m_pGraphicsView = new QGraphicsView(pGraphicsScene, this);

setCentralWidget(m_pGraphicsView);

QObject::connect(m_pCustomGraphicsProxy1, SIGNAL(sigNewFileDragDropped()), this, SLOT(sloPlayOnWindow1()));
QObject::connect(m_pCustomGraphicsProxy2, SIGNAL(sigNewFileDragDropped()), this, SLOT(sloPlayOnWindow2()));

//just for testing - this gives only audio no video can be seen
m_pMediaPlayer1->setMedia(QUrl::fromLocalFile("d:/z.avi"));
m_pMediaPlayer1->play();

<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?

wysota
30th December 2012, 17:56
If you want to use GraphicsView then the only viable option I see is to use QGraphicsVideoItem. However if you want to use Qt5, I suggest you take a look at what QML/QtQuick has to offer.

ustulation
30th December 2012, 18:38
thank you. I'll look into QtQuick (frankly, i do not know what that is). In the mean time could you tell me if QtMultimedia is as powerful as Phonon (though i could not go much deeper into phonon too because of the reasons i mentioned)? i mean if manipulations of audio, video (alpha blending of frames from two videos etc) etc are required? Also you said
If you want to use GraphicsView.. what else would you suggest if i want the capabilities of individual video rotating, scaling etc.

wysota
30th December 2012, 19:43
I'll look into QtQuick (frankly, i do not know what that is).
Do that as soon as possible.


In the mean time could you tell me if QtMultimedia is as powerful as Phonon
Yes. However it operates on a lower level than Phonon.

i mean if manipulations of audio, video (alpha blending of frames from two videos etc) etc are required?
Nothing is required. You can just tell it to play and it will play. If you want to do some advanced stuff, QtMultimediaKit (Qt4) and QtMultimedia (Qt5) will allow you to access individual frames. You can also do a lot of things easily in QtQuick2.


Also you said what else would you suggest if i want the capabilities of individual video rotating, scaling etc.
Scaling and rotating is easy.