Migrating Settings from Qt5 to Qt6
-
I have this widgets based codebase I need to migrate to Qt6, where they set default settings for QtWebEngineWidgets web engine that looks like this (because it's a web app embedded in a Qt resource file that has to load locally):
//allow loading local files (file:// URLs) from embedded chromium char ARG_DISABLE_WEB_SECURITY[] = "--disable-web-security"; int newArgc = argc+1+1; char** newArgv = new char*[static_cast<size_t>(newArgc)]; for(int i=0; i<argc; i++) { newArgv[i] = argv[i]; } newArgv[argc] = ARG_DISABLE_WEB_SECURITY; newArgv[argc+1] = nullptr; QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication a(argc, argv); QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, true); QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true); QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true);
Problem is defaultSettings() is gone, and I don't see a straight path in the documentation to use another class/function to replace it.
Please help, any suggestions are welcome!
-
thanks for the reply @mpergand
Does that mean that on the new API, there's no way to set it as a static method so it's global for all pages and I'll have to set the profile and use it as a global variable instead of just configuring defaults at class level?EDIT: never mind, fixed it using something like this from your suggestion, thanks!
QWebEngineProfile::defaultProfile()->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, true);
-