qwebkit

Qt how to insert html into an editable QWebView at the cursor position?

帅比萌擦擦* 提交于 2019-12-06 07:31:07
I'm trying to use QWebView to implement a blog post editor. And I have some sample html snippets to insert into the editor by triggering menu actions. However, it's not convenient as QTextEdit to insert html. As for why I don't use QTextEdit , see my test code following: QTextEdit *edit = new QTextEdit; edit->insertHtml(tr("<div class=\"gci-hello\">Hello</div>")); qDebug() << edit->toHtml(); // --> the div tag disappeared So, if I use QWebView, the div tag will be reserved. But I can't find out how to insert my snippet at the cursor postion on the view. Use execCommand with InsertHTML :

Webkit_server (called from python's dryscrape) uses more and more memory with each page visited. How do I reduce the memory used?

梦想的初衷 提交于 2019-12-06 02:39:20
I am writing a scrapper using dryscrape in python3 . I am trying to visit hundreds of different urls during a scrapping session and click through about 10 ajax pages on each url (without visiting a different url per ajax page). I need something like dryscrape because I need to be able to interact with javascript components. The classes I wrote for my needs work, but I am running out of memory when I am have visited about 50 or 100 pages (all 4Gbs of memory are used and 4Gbs of swap disk space is virtually 100% full). I looked at what is using up the memory and it appears that webkit_server

How to get path of a python module ( not sys.executable )

懵懂的女人 提交于 2019-12-05 20:18:03
问题 I need to get Path for PyQt library in python program. Program is run as a script from another application, therefore my sys.executable = 'D:/program files/visum/exe/visum115.exe and I need my actual python path (and path for PyQt library module) Path = C:\Python25\Lib\site-packages\PyQt4\plugins im trying with os.environ['PYTHONPATH'] but I'm not sure if it can be robust. Regards! PS. I need it to be able to plug plugins: qApp.addLibaryPath('C:\Python25\Lib\site-packages\PyQt4\plugins') 回答1:

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

How to get QWebKit to display image?

社会主义新天地 提交于 2019-12-04 04:47:14
Okay, I have a Qt executable in the same directory as a file logo.png . I call the following: QString msg("<html><body><img src='logo.png' /></body></html>"); webView->setHtml(msg); where webview is the QWebKit pointer However, when I execute the program, the image does not display. I am executing the program from the directory that the image is in... why won't it display? This is driving me nuts! The logo.png may not be resolved properly if a appropriate baseUrl is not given. Here is an example. Note that the application must be run from the directory containing logo.png, but the dummy.html

How to get path of a python module ( not sys.executable )

ε祈祈猫儿з 提交于 2019-12-04 03:45:25
I need to get Path for PyQt library in python program. Program is run as a script from another application, therefore my sys.executable = 'D:/program files/visum/exe/visum115.exe and I need my actual python path (and path for PyQt library module) Path = C:\Python25\Lib\site-packages\PyQt4\plugins im trying with os.environ['PYTHONPATH'] but I'm not sure if it can be robust. Regards! PS. I need it to be able to plug plugins: qApp.addLibaryPath('C:\Python25\Lib\site-packages\PyQt4\plugins') you can try to load the module and after check for it's __ file __ attribute to get the path of the .pyc

Using QWebEngine to render an image

风格不统一 提交于 2019-12-04 03:20:14
I'm looking to replace QWebKit with QWebEngine in my headless renderer. I initialise the page with load() and connect a slot to loadFinished() to generate the final .PNG image. This used to work fine with WebKit but fails with QWebEngine . Code is as follows... _webView = new QWebEngineView(); .... // Render the HTML to an image QPainter painter(&image); _webView->page()->view()->render(&painter); painter.end(); I receive the following errors : "Asking for share context for widget that does not have a window handle" "QOpenGLWidget: Cannot be used without a context shared with the toplevel".