QVideoWidget *pVideoWidget1 = new QVideoWidget(0);
QVideoWidget *pVideoWidget2 = new QVideoWidget(0);
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);
QGraphicsLinearLayout *pGraphicsLinearLayout = new QGraphicsLinearLayout;
CustomGraphicsProxy* button = new CustomGraphicsProxy(0);
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();
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();
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();
To copy to clipboard, switch view to plain text mode
Bookmarks