How to disable web security policy? I tried many ways but failed. I use qt5.9.2
-
wrote on 19 Mar 2018, 02:35 last edited by kingstyingThis post is deleted!
-
wrote on 19 Mar 2018, 03:24 last edited by
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?
-
wrote on 19 Mar 2018, 07:10 last edited by
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.
-
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.
wrote on 19 Mar 2018, 07:17 last edited by@ambershark Could you tell me how to solve this problem?
-
@ambershark Could you tell me how to solve this problem?
wrote on 19 Mar 2018, 07:20 last edited by@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.
-
wrote on 22 Mar 2018, 06:45 last edited byThis post is deleted!
-
wrote on 22 Mar 2018, 13:51 last edited by
I'm using the flag "--disable-web-security" with QWebEngineView with success on Qt 5.9.X and Qt 5.10
I don't use "--allow-file-access-from-files" flag since I don't need to access local files ...
-
I'm using the flag "--disable-web-security" with QWebEngineView with success on Qt 5.9.X and Qt 5.10
I don't use "--allow-file-access-from-files" flag since I don't need to access local files ...
wrote on 23 Mar 2018, 01:34 last edited by@DeeeZ Thanks you very much. Could you please tell me how do you pass the "--disable-web-security" argument to QWebEngineView? Do you pass it to QApplication object?
-
wrote on 23 Mar 2018, 07:52 last edited by
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);
6/9