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);
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章