Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get Source code of QWebEnginePage
Forum Updated to NodeBB v4.3 + New Features

Get Source code of QWebEnginePage

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AmrCoder
    wrote on 14 Oct 2017, 18:48 last edited by
    #1

    when I press left click on any web page in webEngineview I have the option to view the source code for the current page.
    that I want to do it programming I want to set this page source code to a QString so I can do what I want with it
    I tried both
    QWebEnginePage.toHtml() and toPlaintText but both not give me as I found in the left click view page source code from the view
    for example, i tried on facebook page toHtml give me codes and the view page source code give me a more detailed code that what I want so any help to get this code to QString
    thanks in advance

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on 14 Oct 2017, 20:29 last edited by
      #2

      Hi! Don't know why toHtml() and right-click-view disagree. Maybe you can use the following as a work-around. It gives the exact content of the right-click-view:

      ui->webEngineView->setUrl(QUrl("view-source:https://facebook.com"));
      // ...
      // on load finished:
      ui->webEngineView->page()->toPlainText( [this](QString const &s){ ui->plainTextEdit->setPlainText(s); } );    
      
      1 Reply Last reply
      1

      1/2

      14 Oct 2017, 18:48

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved