I have created a QLabel and play a video inside this QLabel in QT using phonon.(videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, movieLabel) Now, As you know the shape of this QLabel is rectangular. I want this QLabel to get a form of a Circle. So, that the video is played inside a circle rather than having rectangular shape.
this is the showing movie part:
void VideoPlayer::startMovieSlot()
{
Phonon::MediaObject *media;
Phonon::VideoPlayer *videoPlayer;
media = new Phonon::MediaObject();
media
->setCurrentSource
(Phonon
::MediaSource(QString("./sample.mpg4")));
videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, movieLabel);
// videoPlayer->setFixedSize(QSize(400, 300));
videoPlayer->setFixedSize(800, 500);
// videoPlayer->move(1280-400, 0);
videoPlayer->show();
connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));
videoPlayer->play(media->currentSource());
}
void VideoPlayer::startMovieSlot()
{
Phonon::MediaObject *media;
Phonon::VideoPlayer *videoPlayer;
media = new Phonon::MediaObject();
media->setCurrentSource(Phonon::MediaSource(QString("./sample.mpg4")));
videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, movieLabel);
// videoPlayer->setFixedSize(QSize(400, 300));
videoPlayer->setFixedSize(800, 500);
// videoPlayer->move(1280-400, 0);
videoPlayer->show();
connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));
videoPlayer->play(media->currentSource());
}
To copy to clipboard, switch view to plain text mode
Now, I want to create the video QLabel and put the output in a round label not a rectangular one, I have drawn a png circle for that to set it on the video:
VideoPlayer
::VideoPlayer(QWidget *parent
){
// movie = new QMovie(this);
// movie->setCacheMode(QMovie::CacheAll);
qDebug() << "VideoPlayer";
movieLabel
= new QLabel(tr
("No movie loaded"));
movieLabel->setAlignment(Qt::AlignCenter);
movieLabel->setMaximumSize(800, 500);
movieLabel
->setBackgroundRole
(QPalette::Dark);
movieLabel->setAutoFillBackground(true);
circle
= new QPixmap("./circle.png");
imageBox->setPixmap(*circle);
// currentMovieDirectory = "movies";
// startMovieSlot();
// createControls();
createButtons();
// connect(movie, SIGNAL(frameChanged(int)), this, SLOT(updateFrameSlider()));
// connect(movie, SIGNAL(stateChanged(QMovie::MovieState)),
// this, SLOT(updateButtons()));
// connect(fitCheckBox, SIGNAL(clicked()), this, SLOT(fitToWindow()));
// connect(frameSlider, SIGNAL(valueChanged(int)), this, SLOT(goToFrame(int)));
// connect(speedSpinBox, SIGNAL(valueChanged(int)),
// movie, SLOT(setSpeed(int)));
mainLayout->addWidget(movieLabel);
mainLayout->addWidget(imageBox);
// mainLayout->addLayout(controlsLayout);
mainLayout->addLayout(buttonsLayout);
setLayout(mainLayout);
// updateFrameSlider();
// updateButtons();
setWindowTitle(tr("Movie Player"));
// resize(400, 400);
resize(1024, 786);
}
VideoPlayer::VideoPlayer(QWidget *parent)
: QWidget(parent)
{
// movie = new QMovie(this);
// movie->setCacheMode(QMovie::CacheAll);
qDebug() << "VideoPlayer";
movieLabel = new QLabel(tr("No movie loaded"));
movieLabel->setAlignment(Qt::AlignCenter);
movieLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
movieLabel->setMaximumSize(800, 500);
movieLabel->setBackgroundRole(QPalette::Dark);
movieLabel->setAutoFillBackground(true);
circle = new QPixmap("./circle.png");
imageBox = new QLabel;
imageBox->setPixmap(*circle);
// currentMovieDirectory = "movies";
// startMovieSlot();
// createControls();
createButtons();
// connect(movie, SIGNAL(frameChanged(int)), this, SLOT(updateFrameSlider()));
// connect(movie, SIGNAL(stateChanged(QMovie::MovieState)),
// this, SLOT(updateButtons()));
// connect(fitCheckBox, SIGNAL(clicked()), this, SLOT(fitToWindow()));
// connect(frameSlider, SIGNAL(valueChanged(int)), this, SLOT(goToFrame(int)));
// connect(speedSpinBox, SIGNAL(valueChanged(int)),
// movie, SLOT(setSpeed(int)));
mainLayout = new QVBoxLayout;
mainLayout->addWidget(movieLabel);
mainLayout->addWidget(imageBox);
// mainLayout->addLayout(controlsLayout);
mainLayout->addLayout(buttonsLayout);
setLayout(mainLayout);
// updateFrameSlider();
// updateButtons();
setWindowTitle(tr("Movie Player"));
// resize(400, 400);
resize(1024, 786);
}
To copy to clipboard, switch view to plain text mode
my way to solve this problem was this:
circle
= new QPixmap("./circle.png");
imageBox->setPixmap(*circle);
circle = new QPixmap("./circle.png");
imageBox = new QLabel;
imageBox->setPixmap(*circle);
To copy to clipboard, switch view to plain text mode
but this method doesn't work, moreover the program finishes unexpectedly when I add:
mainLayout->addWidget(imageBox);
mainLayout->addWidget(imageBox);
To copy to clipboard, switch view to plain text mode
any idea how I can show the video output in a circle rather a rectangle?
Bookmarks