4

I am trying to display a web page using the below code

    QWebView *view = new QWebView();
    view->load(QUrl("qrc://images//sample page.html/"));
    view->show();

sample page.html is added to project resources/Images. The web page frame is loading, but I can't see any html data.

I tested with the below web url and it loaded the page

   view->load(QUrl("http://www.google.com/"));
1
  • Thanks to all, I found the issue view->load(QUrl("qrc:/Images/Folder Location.html")); Commented May 30, 2012 at 21:18

1 Answer 1

3

You will have to go through a few steps as follows:

1) Get the QWebPage object:

 QWebPage *page = view->page();

2) Get the QWebFrame object:

 QWebFrame *frame = page->currentFrame();

3) Call the toHtml member function on the current frame:

 QString html = frame->toHtml();

Of course, you will need to add appropriate error checks in between.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.