使用PyQt5 QWebEngineView,我在观看视频时无法使用fullScreen:
import sys
from PyQt5 import QtWidgets, QtGui, QtCore
from PyQt5.QtWebEngineWidgets import *
app=QtWidgets.QApplication(sys.argv)
w=QWebEngineView()
w.settings().setAttribute(QWebEngineSettings.PluginsEnabled, True)
w.settings().setAttribute(QWebEngineSettings.JavascriptEnabled, True)
w.settings().setAttribute(QWebEngineSettings.FullScreenSupportEnabled, True)
w.page().fullScreenRequested.connect(QWebEngineFullScreenRequest.accept)
w.load(QtCore.QUrl('56.com/w94/play_album-aid-14364505_vid-MTQ3NDUxMjY3.html'))
w.showMaximized()
app.exec_()
答案 0 :(得分:0)
QWebEnginePage :: fullScreenRequested信号的参数名为" request"它有一个名为" accept()"的函数。所以你必须致电
request.accept()
但是你的代码使用了类型名称(QWebEngineFullScreenRequest),并没有引用这个确切的对象。
https://doc.qt.io/qt-5/qwebenginepage.html#fullScreenRequested
答案 1 :(得分:0)
您可以参考以下代码:
m_webView->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
connect(m_webView->page(), &QWebEnginePage::fullScreenRequested, this, [this]
(QWebEngineFullScreenRequest fullScreenRequest) {
fullScreenRequest.accept();
qDebug()<<"UI: fullScreenRequested: "<<fullScreenRequest.toggleOn()<<endl;
});