QWebengineView 对自定义协议的拦截处理

重新实现 TNWebEnginePage 的 acceptNavigationRequest 函数:

// If the function returns true, the navigation request is accepted and url is loaded.
bool MyWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
{
	if (isMainFrame)
	{
		QString resUrl = url.toString(QUrl::DecodeReserved);
        
		if (resUrl.startsWith(QStringLiteral("myprotocol://"), Qt::CaseInsensitive))
		{
			//handleMyProtocol(resUrl);
			
			return false;
		}
	}

    return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
}

猜你喜欢

转载自blog.csdn.net/e5max/article/details/79355849