本文整理汇总了C++中QWebEngineView::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebEngineView::setAttribute方法的具体用法?C++ QWebEngineView::setAttribute怎么用?C++ QWebEngineView::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebEngineView
的用法示例。
在下文中一共展示了QWebEngineView::setAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayHtml
void QRestClient::displayHtml(QByteArray html)
{
QWebEngineView *view = new QWebEngineView();
view->setAttribute(Qt::WA_DeleteOnClose);
view->setHtml(html);
view->show();
}
示例2: loginInteractive
void LoginManager::loginInteractive()
{
QWebEngineView* webView = new QWebEngineView;
webView->setWindowModality(Qt::ApplicationModal);
webView->setAttribute(Qt::WA_DeleteOnClose);
QWebEnginePage* page = webView->page();
QWebEngineProfile* profile = page->profile();
// TODO: logout in editor does not log out in web view
profile->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies);
profile->setRequestInterceptor(new ApiWebEngineRequestInterceptor(profile));
//workaround for the crashes sometimes happend in Chromium on macOS with Qt 5.12
connect(webView, &QWebEngineView::renderProcessTerminated, this, [profile, webView](QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode)
{
qDebug() << "Login page loading terminated" << terminationStatus << " " << exitCode;
profile->clearHttpCache();
webView->show();
});
connect(page, &QWebEnginePage::loadFinished, this, [this, page, webView](bool ok) {
if (!ok)
return;
constexpr QUrl::FormattingOptions cmpOpt = QUrl::RemoveQuery | QUrl::RemoveFragment | QUrl::StripTrailingSlash;
if (!page->url().matches(ApiInfo::loginSuccessUrl, cmpOpt))
return;
page->runJavaScript("JSON.stringify(muGetAuthInfo())", [this, page, webView](const QVariant& v) {
onLoginReply(nullptr, HTTP_OK, QJsonDocument::fromJson(v.toString().toUtf8()).object());
// We have retrieved an access token, do not remain logged
// in with web view profile.
page->profile()->cookieStore()->deleteAllCookies();
webView->close();
});
});
webView->load(ApiInfo::loginUrl);
webView->show();
}
示例3: openPDFWindow
void MainWindow::openPDFWindow(QString url){
QWebEngineView * pdfView;
if(!pdfViewList.contains(url)){
pdfView = new QWebEngineView(0);
QUrl theurl = QUrl(url);
pdfView->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
pdfView->load( theurl );
pdfView->show();
pdfViewList.insert(url, pdfView);
pdfView->setAttribute(Qt::WA_DeleteOnClose);
pdfView->showNormal();
int frameHeight = pdfView->frameGeometry().height()-pdfView->geometry().height();
pdfView->move( (screenRect.width() - 640)/2, screenRect.y() );
pdfView->resize( 640, screenRect.height()-frameHeight );
connect(pdfView, SIGNAL(destroyed(QObject*)), this, SLOT(onPDFViewClose(QObject*)) );
//pdfView->settings()->enablePersistentStorage(QDir::tempPath());
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
}else{