How to disable web security policy? I tried many ways but failed. I use qt5.9.2
-
This post is deleted!
-
I run QWebEngineView browser on my arm board. The browser page can not display normally. I think it is "Same Origin Policy" stop the browser loading some files. I have tried three ways, but it seems to useless.
First way,
webView->page()->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
webView->page()->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, true);Second way,
Pass argument "--disable-web-security" or "--disable-web-security --user-data-dir='mydir' " to QApplication object.
Third way,
Pass argument "--allow-file-access-from-files" to QApplication object, useless. But i tried command "chrome.exe --allow-file-access-from-files" on Windows, it success.Anyone can give me some suggestions?
-
Removed duplicate https://forum.qt.io/topic/88930/qwebengine-browser-can-not-disable-web-security.
Please don't post the same question multiple times. I am erasing the other one.
-
@ambershark Could you tell me how to solve this problem?
-
@kingstying Sorry I haven't used QWebEngine components enough to offer much advice there. And in the little I have used them I've never had to mix remote/local files that require security overrides.
Hopefully someone else who has done it can chime in here.
-
This post is deleted!
-
Like this:
QStringList argumentsAdded;
...
argumentsAdded.append("--disable-web-security");
...
int i = 0;
int new_argc = argc + argumentsAdded.size();
char** new_argv = (char **) malloc((new_argc + 1) * sizeof (char *));// Store previous arguments for(i = 0; i < argc; i++) { size_t length = strlen(argv[i])+1; new_argv[i] = (char *) malloc(length); memcpy(new_argv[i], argv[i], length); } // Store new arguments i=0; foreach(QString s, argumentsAdded) { new_argv[argc + i] = new char[s.toLocal8Bit().size()+1]; strcpy( new_argv[argc + i], s.toLocal8Bit().constData()); i++; } // Finish array with NULL value new_argv[new_argc] = NULL; // Create a single application to avoid to have several instance QtSingleApplication singleApp(new_argc, new_argv);