Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Migrating Settings from Qt5 to Qt6
Forum Updated to NodeBB v4.3 + New Features

Migrating Settings from Qt5 to Qt6

Scheduled Pinned Locked Moved Solved QtWebEngine
3 Posts 2 Posters 601 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raulgd
    wrote on last edited by
    #1

    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!

    Raul Guerrero
    http://jimi.mx

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by
      #2

      Try:
      QWebEngineProfile* profile=QWebEngineProfile::defaultProfile();
      QWebEngineSettings *defaultSettings = profile->settings();

      1 Reply Last reply
      1
      • R Offline
        R Offline
        raulgd
        wrote on last edited by raulgd
        #3

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

        Raul Guerrero
        http://jimi.mx

        1 Reply Last reply
        0
        • R raulgd has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved