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. QWebEngine DemoBrowser retrieve cookies and current URL

QWebEngine DemoBrowser retrieve cookies and current URL

Scheduled Pinned Locked Moved Unsolved General and Desktop
qwebengineqwebenginepageqwebengineviewcookies
1 Posts 1 Posters 3.6k 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.
  • M Offline
    M Offline
    Maxx Dovahkiin
    wrote on last edited by Maxx Dovahkiin
    #1

    Hi, I'm using the QWebEngine DemoBrowser in my application. As this is really a full fledged browser, so i'm not sure about how to actually retrieve the cookies for a specific page.

    Normally using a single QWebEngineView i would do the following to retrieve the cookies

    QWebEngineCookieStore *browser_cookie_store = ui->browser->page()->profile()->cookieStore();
    connect( browser_cookie_store, &QWebEngineCookieStore::cookieAdded, this, &Terminal::handleCookieAdded );
    
    

    And the slot would be written as such

    void Terminal::handleCookieAdded(const QNetworkCookie &cookie)
    {
      cookie_jar->insertCookie( cookie );
      //qDebug() << cookie.toRawForm() << "\n\n\n";
    }
    

    And to check the current URL i would normally do this

    /* Connect the urlChanged signal */
     connect( ui->browser, &QWebEngineView::urlChanged, this, &Terminal::checkCurrentURL );
    
    /* checkCurrentURL SLOT */
    void Terminal::checkCurrentURL(const QUrl &url)
    {
      if ( url.url() == "https://www.certainwebsite.com" ) {
        qDebug() << "Logged into " << url.toDisplayString();
        emit loggedIntoTerminal();
      }
    }
    

    But how to actually achieve this using the DemoBrowser provided with Qt WebEngine example.

    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