|
5#
楼主 |
发表于 2018-5-15 17:44:48
|
只看该作者
.pro- equals(QT_MAJOR_VERSION, 5)
- lessThan(QT_MINOR_VERSION, 7): QT += webkitwidgets
- equals(QT_MAJOR_VERSION, 5)
- greaterThan(QT_MINOR_VERSION, 7): QT += webenginewidgets
复制代码 .h- #if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0))
- #include <QtWebEngineWidgets>
- #else
- #include <QWebView>
- #include <QWebSettings>
- #endif
- #if QT_VERSION >= 0x050700
- QWebEngineView * engineView;
- #else
- QWebView* webView;
- QWebSettings *websetting;
- #endif
复制代码 .cpp- #if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0))
- #include <QWebEngineSettings>
- #endif
- #if QT_VERSION >= 0x050700
- QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings();
- defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, true);
- engineView= new QWebEngineView(ui->page);
- mainLayout->addWidget(engineView);
- engineView->setUrl(QUrl("http://www.firemail.wang:8088/chunhui_resource/preschool/letters/a.swf"));//
- engineView->show();
- #else
- websetting = QWebSettings::globalSettings();
- websetting->setAttribute(QWebSettings::PluginsEnabled, true);
- // websetting->setAttribute(QWebSettings::JavaEnabled, true);
- websetting->setAttribute(QWebSettings::JavascriptEnabled, true);
- websetting->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);//
- websetting->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
- webView= new QWebView(ui->page);
- mainLayout->addWidget(webView);
- webView->load(QUrl("http://www.baidu.com"));//
- webView->show();
- #endif
复制代码 |
|