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. "ERR_NETWORK_ACCESS_DENIED" appears when loading local HTML with QWebEngineView
Forum Update on Monday, May 27th 2025

"ERR_NETWORK_ACCESS_DENIED" appears when loading local HTML with QWebEngineView

Scheduled Pinned Locked Moved Solved QtWebEngine
2 Posts 1 Posters 292 Views
  • 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.
  • B Offline
    B Offline
    Buns
    wrote on last edited by
    #1

    The C++ source code is as follows:

    QVBoxLayout *layout = new QVBoxLayout;
    m_view = new QWebEngineView();
    layout->addWidget(m_view);
    ui->widget->setLayout(layout);
    
    QString filepath = qApp->applicationDirPath() + "/test.html";
    m_view->load(QUrl(filepath));
    

    and the HTML file is as follows:

    <!DOCTYPE html> 
    <html lang="en"> 
    <head> 
    	<meta charset="UTF-8"> 
    	<meta http-equiv="refresh" content="0;url=http://baidu.com/"> 
    </head> 
    <body> </body> 
    </html>
    

    When the program was running, an error occurred:
    ![alt text](0e2d317c-065a-4f2d-81b4-ba45987aa9a9-image.png image)
    "Please, could anyone tell me how to solve this issue? I would be very grateful."

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Buns
      wrote on last edited by
      #2

      I have already solved this problem. The solution is:

      m_view->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
      
      1 Reply Last reply
      0
      • SGaistS SGaist 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