Qt的QVideoWidget全屏设置异常
系统:windows11,Qt:6.2.4
首先通过重写双击鼠标事件如下:
void MainPanel::mouseDoubleClickEvent(QMouseEvent *event)
{
//m_videoWidget为QVideoWidget的new对象
qDebug()<<"m_videoWidget.isFullScreen():"<<m_videoWidget->isFullScreen();//测试打印
m_videoWidget->setFullScreen(!m_videoWidget->isFullScreen());
}
运行后第一次双击时能实现全屏,并且能打印isFullScreen();的值,但是全屏状态下再次双击就不进入mouseDoubleClickEvent,界面也没有反应,而且无任何打印输出。甚至我写了esc取消全屏的事件也没用。。
然后我修改了代码,加了个定时器
timer->setSingleShot(true);
m_videoWidget->setFullScreen(m_videoWidget->isFullScreen());
connect(timer,&QTimer::timeout,this,[=](){
qDebug()<<"m_videoWidget.isFullScreen():"<<m_videoWidget->isFullScreen();//测试打印
m_videoWidget->setFullScreen(false);
});
timer->start(3000);
发现这样在第一次双击全屏后过3秒能正常打印isFullScreen()也能正常取消全屏。
这是什么情况