Enter this code "from PySide2.QtWebKit import QWebView" to VRED 2018.3 (10.11) terminal the result is:
root: from PySide2.QtWebKit import QWebView
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named QtWebKit
Does that mean pyside2 is limited and can't deal with QWebView (i.e. to emulate a browser) ??
Solved! Go to Solution.
Solved by sinje_thiedemann. Go to Solution.
Solved by michael_nikelsky. Go to Solution.
QtWebkit is deprecated and therefore no longer supported. You should use QWebEngine instead: http://doc.qt.io/qt-5/qtwebenginewidgets-qtwebkitportingguide.html
Kind regards
Michael
Hmm??
I'm not sure what you mean with: use QWebEngineView?!
In fact this doesn'r work either:
root: from PySide2.QWebEngine import *
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named QWebEngine
Hi,
it should be
from PySide2.QtWebEngineWidgets import QWebEngineView
For example:
from PySide2.QtWebEngineWidgets import QWebEngineView
from PySide2.QtCore import QUrl
view = QWebEngineView()
view.load(QUrl("https://wiki.qt.io/PySide2"))
view.show()
Kind regards
Michael
That's a big progress !!!
But I have still some strange problem:
This code works fine:
# -*- coding: utf-8 -*-
import sys
try: # Version 2018+
from PySide2.QtWebEngineWidgets import QWebEngineView
from PySide2.QtCore import QUrl
except ImportError:
print "Uuups, can't import all needed stuff"
if __name__ == '__main__':
view = QWebEngineView()
view.load(QUrl("https://wiki.qt.io/PySide2"))
view.show()
But the folowing code doesn't show anything !!! ????
# -*- coding: utf-8 -*-
import sys
try: # Version 2018+
from PySide2.QtWebEngineWidgets import QWebEngineView
from PySide2.QtCore import QUrl
except ImportError:
print "Uuups, can't import all needed stuff"
def run():
view = QWebEngineView()
view.load(QUrl("https://wiki.qt.io/PySide2"))
view.show()
if __name__ == '__main__':
run()
So question: What's wrong with that???
The view object you create in run() goes out of scope at the end of run, so the widget is deleted again and you don't see it.
Move the code from run() into a class:
# -*- coding: utf-8 -*- import sys try: # Version 2018+ from PySide2.QtWebEngineWidgets import QWebEngineView from PySide2.QtCore import QUrl except ImportError: print "Uuups, can't import all needed stuff" class View: def __init__(self): self.view = QWebEngineView() self.view.load(QUrl("https://wiki.qt.io/PySide2")) self.view.show() if __name__ == '__main__': view = View()
Kind regards
Sinje
Can't find what you're looking for? Ask the community or share your knowledge.