qtwebkit

catch link clicks in QtWebView and open in default browser

泄露秘密 提交于 2019-12-22 05:01:02
问题 I am opening a page in QtWebView (in PyQt if that matters) and I want to open all links in the system default browser. I.e. a click on a link should not change the site in the QtWebView but it should open it with the default browser. I want to make it impossible to the user to change the site in the QtWebView. How can I do that? Thanks, Albert 回答1: That does it: import sys, webbrowser from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * app = QApplication(sys.argv

How to choose value from an option list using PyQt4.QtWebKit

眉间皱痕 提交于 2019-12-21 18:27:26
问题 I'm trying to auto-select a birthday from an option list on my website by using PyQt4.QtWebKit, but I'm having trouble doing this. When I want to select a radio button I do this: doc = webview.page().mainFrame().documentElement() g = doc.findFirst("input[id=gender]") g.setAttribute("checked", "true") Or set some text input: doc = webview.page().mainFrame().documentElement() s = doc.findFirst("input[id=say_something]") s.setAttribute("value", "Say Hello To My Little Friends") But how do I

How to set the size of browser using QtWebKit

☆樱花仙子☆ 提交于 2019-12-21 02:41:13
问题 Recently I use PyQt4 to crawl some web pages. I want to set different size of the browser which is generated by QWebView().show() . I tried to use the following code snippet to set the size: self.qsize = QWebPage().viewportSize() self.qsize.setHeight(3000) self.qsize.setWidth(1000) print self.qsize.height() print self.qsize.width() But the browser displayed is always the same size. Please give me some tips on how to set the size of the browser displayed by QWebView . Thanks in advance. 回答1: I

Use PyQt5.QtWebEngineWidgets on Windows: is it possible?

与世无争的帅哥 提交于 2019-12-19 12:02:01
问题 I am trying to build an app in PyQt5 (version 5.6+) in Python 3.6. It contains a web browser, using QtWebEngineWidgets. It works fine on Mac, however, there are problems on Windows. When I run the code on Windows and import the module: from PyQt5 import QtWebEngineWidgets I get the following error: ImportError: cannot import name 'QtWebEngineWidgets' Now, reading some forums it looks like PyQt5.QtWebEngineWidgets is not available for Windows, yet. Is it correct? How can I have a web browser

Use PyQt5.QtWebEngineWidgets on Windows: is it possible?

£可爱£侵袭症+ 提交于 2019-12-19 12:01:34
问题 I am trying to build an app in PyQt5 (version 5.6+) in Python 3.6. It contains a web browser, using QtWebEngineWidgets. It works fine on Mac, however, there are problems on Windows. When I run the code on Windows and import the module: from PyQt5 import QtWebEngineWidgets I get the following error: ImportError: cannot import name 'QtWebEngineWidgets' Now, reading some forums it looks like PyQt5.QtWebEngineWidgets is not available for Windows, yet. Is it correct? How can I have a web browser

Qt WebKit On Mobile

强颜欢笑 提交于 2019-12-18 08:58:53
问题 I am trying to render a web page. Qt says their QtWebKit is available for mobile since 4.8 here If you want to target mobile devices you should consider using QGraphicsWebView instead of QWebView. Both of them is under QtWebKit. So what am I missing? 回答1: If you are talking about Android and iOS, it's just a no-no. Citing Digia from the release page of Qt 5.2: Qt Webkit is not supported on Android and we are working on providing a cross-platform API to integrate web content into mobile apps.

how to get response in QtWebKit

耗尽温柔 提交于 2019-12-18 04:17:10
问题 im beginner with QtWebKit i build simple web frame that loaded page ( server side ) and when from this page i submit data i like to catch the response string from the server in the c++ side how can i do that ? 回答1: I tinkered around with Qt (which I'm new to) and found a way to catch all resources downloaded by WebKit. Here's how: 1) Create your own subclass of QNetworkAccessManager 2) In your derived class, override virtual function createRequest 3) Call base class implementation to get the

Capture server response with QWebEngineView

十年热恋 提交于 2019-12-17 19:56:02
问题 I'm trying to create a Dialog in Qt which loads a URL (which I do not want to expose to the end-user, hence a Dialog). Once the user has entered their credentials on the page, the server returns a redirect URL which I want to capture. How can I do this? QtWebkit made this easy to do as QWebView had a QNetworkAccessManager object. But with QtWebEngine, the QWebEngineView class does not have this capability. The former also allowed HTTP headers to be set for any requests by using the

QtWebkit: How to check HTTP status code?

让人想犯罪 __ 提交于 2019-12-17 19:19:59
问题 I'm writing a thumbnail generator as per an example in the QtWebkit documentation. I would like to avoid screenshots of error pages such as 404 not found or 503 Internal server error . However, the QWebPage::loadFinished() signal is always emitted with ok = true even when the page gives an HTTP error. Is there a way in QtWebkit to check the HTTP status code on a response? 回答1: Turns out you need to monitor the QNetworkAccessManager associated with your QWebPage and wait for a finished(...)

In QtWebkit, how to install the callback from C++ to Javaobject window?

萝らか妹 提交于 2019-12-13 02:30:28
问题 I have implemented the HTML-JS, this calls the C++ method from the JS using QtWebkit . I am able to do it successfully. Now, I want to send a callback to JavaScript window from the C++ method. How can I do so? Here is my code. #include <QtGui/QApplication> #include <QApplication> #include <QDebug> #include <QWebFrame> #include <QWebPage> #include <QWebView> class MyJavaScriptOperations : public QObject { Q_OBJECT public: Q_INVOKABLE qint32 MultOfNumbers(int a, int b) { qDebug() << a * b;