Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Set History to a QWebPage

Set History to a QWebPage

Scheduled Pinned Locked Moved Qt WebKit
4 Posts 3 Posters 2.2k Views
  • 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.
  • H Offline
    H Offline
    happyangel
    wrote on last edited by
    #1

    hi :
    i am wondering if there is a way to set the history to a QWebPage? i found a history() interface in the QWebPage,but it's const which means we can not set it.
    My scenario is i want to save the previous page's history and set it to the new created page. Does anyone done that before or any ideas? thank you

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nowrep
      wrote on last edited by
      #2

      Save history from QWebView:
      @
      // view is QWebView*
      QByteArray historyData;
      QDataStream historyStream(&historyData, QIODevice::WriteOnly);
      historyStream << *view->history();
      @

      Restore history from QByteArray into QWebView:
      @
      // historyData is QByteArray with previously saved history
      // view is QWebView*
      QDataStream historyStream(historyData);
      historyStream >> *view->history();
      @

      1 Reply Last reply
      0
      • H Offline
        H Offline
        happyangel
        wrote on last edited by
        #3

        this seems not work right, history() doesn't have the ">>" operand method

        [quote author="nowrep" date="1330721372"]Save history from QWebView:
        @
        // view is QWebView*
        QByteArray historyData;
        QDataStream historyStream(&historyData, QIODevice::WriteOnly);
        historyStream << *view->history();
        @

        Restore history from QByteArray into QWebView:
        @
        // historyData is QByteArray with previously saved history
        // view is QWebView*
        QDataStream historyStream(historyData);
        historyStream >> *view->history();
        @[/quote]

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Did you

          @
          #include <QWebHistory>
          @

          ?

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0

          • Login

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