我遇到一个问题,当我在构造函数外部的对话框上调用show()时,Qt会显示警告。
这不是在我的dsktop计算机上,而是在我编译Qt的ARM设备上。我有一个碰撞,显示如下对话框:
SplashVideo::SplashVideo(const QString & videoPath, QWidget * parent)
:QDialog(parent)
{
this->setWindowModality(Qt::ApplicationModal);
m_mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface);
m_videoWidget = new QVideoWidget;
QVBoxLayout * layout = new QVBoxLayout;
layout->addWidget(m_videoWidget);
this->setLayout(layout);
this->setWindowFlags(Qt::FramelessWindowHint);
m_mediaPlayer->setMedia(QUrl::fromLocalFile(videoPath));
m_mediaPlayer->setVideoOutput(m_videoWidget);
connect(m_mediaPlayer, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
this, SLOT(mediaStatusChanged(QMediaPlayer::MediaStatus)));
m_mediaPlayer->play();
}
现在,我有mediaStatusChanged处理程序,我按如下方式调用show(其他事情已完成,但它们并不重要):
void SplashVideo::mediaStatusChanged(QMediaPlayer::MediaStatus status)
{
if (status == QMediaPlayer::BufferedMedia) {
this->show();
}
}
整个事情以自定义事件循环运行:
SplashVideo video(videoPath);
QEventLoop loop;
QObject::connect(&video, SIGNAL(mediaPlayFinished()), &loop, SLOT(quit()));
loop.exec();
当我运行时,我收到警告:
QWidget::paintEngine: Should no longer be called
QWidget::paintEngine: Should no longer be called
QWidget::paintEngine: Should no longer be called
QWidget::paintEngine: Should no longer be called
但是,如果我在构造函数中调用show,一切都很好。此外,这只发生在我的基于Linux的ARM设备上。在桌面Linux系统上,它很好。