PDA

View Full Version : how to attach the video player window into my Mainwidow



saman_artorious
11th July 2012, 10:51
Hi,

the following code creates a video player object and shows mp4 video in a seperate window. Though, this is not exactly what i want.
I need to create a movie widget inside the main window, should be located in the middle, with some buttons n slider added to the other sides of it.

As, I am new to Qt graphics, I don't know what to add to this code.
would anyone help me revising the code please.

Yours



#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <phonon/MediaObject>
#include <phonon/VideoPlayer>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

Phonon::MediaObject *media;

media = new Phonon::MediaObject();
media->setCurrentSource(Phonon::MediaSource(QString("/home/saman/4.7/phonon_test/sample.mp4")));

Phonon::VideoPlayer *videoPlayer;

videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory);
videoPlayer->setFixedSize(QSize(400, 300));
videoPlayer->move(1280-400, 0);
videoPlayer->show();

connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));
videoPlayer->play(media->currentSource());
}

MainWindow::~MainWindow()
{
delete ui;
}

amleto
11th July 2012, 10:55
make the widget the mainwindow's central widget
http://qt-project.org/doc/qt-5.0/qmainwindow.html#setCentralWidget

If you are going to be working with Qt for a while then you will need to learn the basics and get familiar with the manual ^^, rather than always ask others to re-write code for you. There are lots of tutorials and examples around.

high_flyer
11th July 2012, 12:48
make the widget the mainwindow's central widget
not good, if you want additional widgets on the sides.

Learn the concept of parenting.