How to add Qvideowidget to second mainwindow
-
Why don't you create that QVideoWidget directly in that second MainWindow ?
By the way, did you really named your class
QApplication1
? If so, that's a very bad idea. -
Then go to the constructor of that class and add your video widget related code there.
Even if nothing serious you should rather use FooClass than deriving names from one of Qt's own classes. You would be surprise by how fast things get serious when developing.
-
Did you set your video player in a layout that you set on your secondary MainWindow all within the constructor of that class ?
-
Did you do exactly how I suggested you to do ?
Can you show the actual code you are using ?
-
@SGaist thanks for your time, this are the code
QWidget *window = new QWidget; QFormLayout *layout = new QFormLayout; QVideoWidget * vw = new QVideoWidget(); QMediaPlayer * mp = new QMediaPlayer(vw); QPushButton *PAUSE = new QPushButton("Pause"); QString vidstring = QFileDialog::getOpenFileName(this, "Select video file", QDir::homePath()); //layout->addWidget(PAUSE); mp->setMedia(QUrl::fromLocalFile(vidstring)); mp->setVideoOutput(vw); layout->addWidget(vw); vw->setGeometry(100, 100, 500, 500); vw->show(); vw->setAttribute(Qt::WA_DeleteOnClose); window->setLayout(layout); mp->play(); window->show();
-
i tried this and it worked i made the QVideowidget the child of the second window and it worked...
QVideoWidget *vw = new QVideoWidget() ; QMediaPlayer * mp = new QMediaPlayer(vw); QString vidstring = QFileDialog::getOpenFileName(this, "Select video file", QDir::homePath()); mp->setMedia(QUrl::fromLocalFile(vidstring)); mp->setVideoOutput(vw); vw->setGeometry(100, 100, 500, 500); vw->setParent(this); vw->show(); mp->play(); }