Hi everyone,
I'm back with a new question.
I have a dialog box which has a button to call QFileDialog::getOpenFileName() to choose a video file.
And the Phonon::VideoPlayer will use the path to play the video.
Now I want to get the width and height of the video. After some searching I try to use VideoPlayer->sizeHint()to get the size while the path is set. The code is like:
void VideoDialog::addVideo() // A slot called by clicked() signal of the button
{
QMessageBox::warning(this, tr
("0"),
QString::number(m_videoPlayer
->sizeHint
().
width()) + " x " + QString::number(m_videoPlayer
->sizeHint
().
height()));
QString videoFile
= QFileDialog::getOpenFileName(.....
);
// The function arguments are removed if(!videoFile.isEmpty()){
m_videoPlayer->mediaObject()->clear();
m_videoPlayer->mediaObject()->setCurrentSource(videoFile);
QMessageBox::warning(this, tr
("1"),
QString::number(m_videoPlayer
->sizeHint
().
width()) + " x " + QString::number(m_videoPlayer
->sizeHint
().
height()));
}
}
void VideoDialog::addVideo() // A slot called by clicked() signal of the button
{
QMessageBox::warning(this, tr("0"), QString::number(m_videoPlayer->sizeHint().width()) + " x " + QString::number(m_videoPlayer->sizeHint().height()));
QString videoFile = QFileDialog::getOpenFileName(.....); // The function arguments are removed
if(!videoFile.isEmpty()){
m_videoPlayer->mediaObject()->clear();
m_videoPlayer->mediaObject()->setCurrentSource(videoFile);
QMessageBox::warning(this, tr("1"), QString::number(m_videoPlayer->sizeHint().width()) + " x " + QString::number(m_videoPlayer->sizeHint().height()));
}
}
To copy to clipboard, switch view to plain text mode
The problem I met is that after I set the video path, the sizeHint is not updated. But if I press the button again, the sizeHint will be the right value. Is there a way to get the sizeHint immediately?
Thanks in advance.
Bookmarks