QUrl requires a schema, and qrc:// for resources. Relevant part of the docs :
By default, resources are available in the application under the same file name as it is in the source tree, with the prefix :/ or URL using the qrc scheme.
For example, the path to the file :/images/cut.png or the URL qrc:///images/cut.png will provide access to the cut.png file, whose location in the application source tree is images/cut.png .
So use this instead:
QtCore.QUrl("qrc:///local_file.html")
Edit
You pass the alias file ( alias="html_home" ):
<qresource prefix="/"> <file alias="html_home">webbrowser_html/program_index.html</file>
Now the path :/html_home , and not :/webbrowser_html/program_index.html
You should use:
QtCore.QUrl("qrc:///html_home")
What will happen in your case:
class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self)
(You should also adjust the ekhumoro solution if you intend to use this. Also note that you are not setting the HTML code of the page in the paste.)
source share