Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Set History to a QWebPage

    Qt WebKit
    3
    4
    1891
    Loading More Posts
    • 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
      happyangel last edited by

      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 Reply Quote 0
      • N
        nowrep last edited by

        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 Reply Quote 0
        • H
          happyangel last edited by

          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 Reply Quote 0
          • G
            goetz last edited by

            Did you

            @
            #include <QWebHistory>
            @

            ?

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post