Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8543965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:26:14+00:00 2026-06-11T12:26:14+00:00

How would you display a local html file using the Qt resource system? The

  • 0

How would you display a local html file using the Qt resource system? The obvious QtCore.QUrl.fromLocalFile(":/local_file.html") doesn’t seem to be the correct syntax.

File mainwindow.qrc (before compilation)

<qresource prefix="/">
    <file alias="html_home">webbrowser_html/program_index.html</file>

File ui_mainwindow:

class Ui_MainWindow(object):    
    def setupUi(self, MainWindow):
        #...
        self.WebBrowser = QtWebKit.QWebView(self.Frame3)

File webbrower.py

from ui_mainwindow import Ui_MainWindow
import mainwindow_rc

class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        self.setupUi(self)
        #...
        stream = QtCore.QFile(':/webbrowser_html/program_index.html')
        if stream.open(QtCore.QFile.ReadOnly):
            home_html = QtCore.QString.fromUtf8(stream.readAll())
            self.WebBrowser.setHtml()
            stream.close()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:26:15+00:00Added an answer on June 11, 2026 at 12:26 pm

    QUrl requires a scheme, and for resources it is qrc://. Relevant part from the docs:

    By default, resources are accessible in the application under the same
    file name as they have in the source tree, with a :/ prefix, or by a
    URL with a qrc scheme.

    For example, the file path :/images/cut.png or the URL
    qrc:///images/cut.png would give access to the cut.png file, whose
    location in the application’s source tree is images/cut.png.

    So, use this instead:

    QtCore.QUrl("qrc:///local_file.html")
    

    Edit

    You are giving the file an alias (alias="html_home"):

    <qresource prefix="/">
        <file alias="html_home">webbrowser_html/program_index.html</file>
    

    Path is now :/html_home, not :/webbrowser_html/program_index.html

    You should use:

    QtCore.QUrl("qrc:///html_home")
    

    Which would be in your case:

    class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
        def __init__(self):
            QtGui.QMainWindow.__init__(self)
    
            self.setupUi(self)
            #...
            self.WebBrowser.load(QtCore.QUrl('qrc:///html_home'))
    

    (You should adjust the ekhumoro’s solution too, if you intend to use that. Also note that you are not setting the HTML of the page in your paste.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an app that would display a remote html and use local
So I have a local HTML file with CSS and I need to display
I am using a UIWebview to display local .html. I want to disable longpress
I have a UIWebView in which I display a HTML file with foreign language
I'm using colorbox to display a separate but local document when a certain link
This was a question about testing file upload functionality using a local java server
I have a label which would display strings from 0 ft to say 999
I want to make an application that would display a message when a user
I want to create application which would display spatial data on Map. I'm thinking
I would like to change admin for a group, so it would display how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.