qwebpage

How get a focus element in QWebView/QWebPage?

爱⌒轻易说出口 提交于 2019-12-11 03:08:42
问题 i need to be able to react on focus changes in QWebPage. I used microFocusChanged() signal and it gives me almost desirable behavior, but anyway i don't know how to know which element is selected. I want to do some actions when any editable element on page gets or loses focus. Thank you in advance 回答1: To handle any HTML event within a page you do the following: Create QObject with callback slots to receive the events. It may be some dedicated handler object or an existing object like your

Receiving multiple loadFinished signals for a requested web page

自作多情 提交于 2019-12-10 18:30:18
问题 I'm receiving multiple loadFinished signals when I attempt to load a QWebPage and I'm not sure what's causing the issue. There were a couple of other questions that seemed to allude to the same problem, but the solutions didn't work for me: QtWebPage - loadFinished() called multiple times Signal QWebPage::loadFinished(bool) returns twice? In the first question, the answer was to connect signals to slots only once," but I already do that. The answer to the second question suggests that I

how to use QWebPage in a non-GUI application

China☆狼群 提交于 2019-12-09 13:35:25
问题 I want to use QWebPage in a non-GUI Qt application. By that, I mean that I don't want to communicate with the window server at all. Using QtGui is not a problem, though. QWebPage internally creates some QWidget instances. Thus, using QCoreApplication is not possible. When creating a QApplication instance though, I already immediately get a MacOSX dock icon. And I don't want that. It also means that it somehow registers itself in Cocoa as a GUI application. My question is not Mac-only. I would

QWebEngineView modify web content before render

↘锁芯ラ 提交于 2019-12-04 19:57:00
I have three questions about QWebengineView (Qt 5.7.0): How can I modify the web content (add extra html/javascript) during load (before render) How can I get events when javascript resource included in webpage is loading ( I want to modify them, too). I get html content by page()->toHtml then set it back by setHtml , but content rendered don't like original (seems to loss format) Thanks for help! 来源: https://stackoverflow.com/questions/38162751/qwebengineview-modify-web-content-before-render

Setting useragent in QWebView

给你一囗甜甜゛ 提交于 2019-12-04 14:31:41
问题 I have a QWebView, which works fine. Then, using code from spynner, I attempt to bind the useragent method to a custom method. This appears to work in spynner (with a QWebPage), but not here. Any help much appreciated. Code: def customuseragent(url): print 'called for %s' % url return 'custom ua' #inside a class self.webkit = QtWebKit.QWebView() self.webkit.page().userAgentForUrl = customuseragent self.webkit.load(QtCore.QUrl('http://www.whatsmyuseragent.com/')) 回答1: I hope this helps... Your

QWebPage triggers loadFinished() several times

倖福魔咒の 提交于 2019-12-04 13:28:26
I'm loading content into QWebPage, using load() method. But my loadStarted(), loadFinished() and loadProgress() handlers are calling several times. How can I detect that page is loaded completely with all it's content? Onur Ozcan Posted a related solution proposal at: Receiving multiple loadFinished signals for a requested web page Basicly look for repaintRequested(QRect) signal of QWebPage. 来源: https://stackoverflow.com/questions/1879881/qwebpage-triggers-loadfinished-several-times

Override shouldInterruptJavaScript in QWebPage with PySide

亡梦爱人 提交于 2019-12-04 06:14:02
问题 I would like to override PySide.QtWebKit.QWebPage.shouldInterruptJavaScript() slot to silently ignore JavaScript interrupt requests. I have my own timeout timer setup and I do not need a default message dialog. Quoting PySide documentation: Because of binary compatibility constraints, this function is not virtual. If you want to provide your own implementation in a PySide.QtWebKit.QWebPage subclass, reimplement the QWebPage.shouldInterruptJavaScript() slot in your subclass instead. QtWebKit

Setting useragent in QWebView

眉间皱痕 提交于 2019-12-03 08:41:48
I have a QWebView, which works fine. Then, using code from spynner, I attempt to bind the useragent method to a custom method. This appears to work in spynner (with a QWebPage), but not here. Any help much appreciated. Code: def customuseragent(url): print 'called for %s' % url return 'custom ua' #inside a class self.webkit = QtWebKit.QWebView() self.webkit.page().userAgentForUrl = customuseragent self.webkit.load(QtCore.QUrl('http://www.whatsmyuseragent.com/')) I hope this helps... Your Code def customuseragent(url): print 'called for %s' % url return 'custom ua' #inside a class self.webkit =

How to tell QWebPage not to load specific type of resources?

五迷三道 提交于 2019-11-27 11:03:38
How to tell QWebPage not to load specific type of resources like js, css or png? The solution is to extend QNetworkAccessManager class and override it's virtual method QNetworkAccessManager::createRequest In our implementation we check the path of the requested url and if it's the one we don't want to download we create and hand over an empty request instead of the real one. Below is a complete, working example. #include <QApplication> #include <QUrl> #include <QtWebKit/QWebPage> #include <QtWebKit/QWebFrame> #include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkRequest>

How to know when a web page is loaded when using QtWebKit?

白昼怎懂夜的黑 提交于 2019-11-27 07:19:49
Both QWebFrame and QWebPage have void loadFinished(bool ok) signal which can be used to detect when a web page is completely loaded. The problem is when a web page has some content loaded asynchronously (ajax). How to know when the page is completely loaded in this case? I haven't actually done this, but I think you may be able to achieve your solution using QNetworkAccessManager . You can get the QNetworkAccessManager from your QWebPage using the networkAccessManager() function. QNetworkAccessManager has a signal finished ( QNetworkReply * reply ) which is fired whenever a file is requested