包含目录:
E:\CPP\lib\07QCefView\include
附加依赖项:
E:\CPP\lib\07QCefView\.build\windows.x86_64\CefViewCore\output\Release\lib\CefViewCore.lib E:\CPP\lib\07QCefView\.build\windows.x86_64\CefViewCore\output\Release\bin\libcef.lib E:\CPP\lib\07QCefView\.build\windows.x86_64\CefViewCore\output\Release\lib\libcef_dll_wrapper.lib E:\CPP\lib\07QCefView\.build\windows.x86_64\example\QCefViewTest\output\Release\bin\QCefView.lib
预处理器:
QCEFVIEW_STATIC=1
以上3项导入 cefPropertySheet 即可
main.php
#include <QCefContext.h> int main(int argc, char* argv[]) { QApplication a(argc, argv); // 构建 QCefConfig QCefConfig config; config.setUserAgent("QCefViewTest"); config.setLogLevel(QCefConfig::LOGSEVERITY_DEFAULT); config.setBridgeObjectName("CallBridge"); config.setRemoteDebuggingPort(9000); config.setBackgroundColor(QColor::fromRgba(qRgba(255, 0, 0, 255))); //添加命令行参数 config.addCommandLineSwitch("enable-media-stream"); config.addCommandLineSwitch("use-mock-keychain"); config.addCommandLineSwitch("allow-file-access-from-files"); config.addCommandLineSwitch("disable-spell-checking"); config.addCommandLineSwitch("disable-site-isolation-trials"); config.addCommandLineSwitch("enable-aggressive-domstorage-flushing"); config.addCommandLineSwitchWithValue("renderer-process-limit", "1"); config.addCommandLineSwitchWithValue("disable-features", "BlinkGenPropertyTrees,TranslateUI,site-per-process"); //用配置信息初始化CEF环境 QCefContext cefContext(&a, argc, argv, &config); jjsoft w; #ifndef USE_JJUSER w.show(); #endif // USE_JJUSER return a.exec(); }
创建一个浏览器窗口:
// build settings for per QCefView QCefSetting setting; // here we just set the default background to blue setting.setBackgroundColor(QColor::fromRgb(0, 0, 255)); // create the QCefView widget and add it to the layout container mainCef = new QCefView("http://www.baidu.com", &setting, this); ui.wg_browser->layout()->addWidget(mainCef);