Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Set cookie before loading url WebEngineView(qml)

Set cookie before loading url WebEngineView(qml)

Scheduled Pinned Locked Moved Solved QtWebEngine
2 Posts 1 Posters 1.8k 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.
  • HojjatJafaryH Offline
    HojjatJafaryH Offline
    HojjatJafary
    wrote on last edited by
    #1

    Hi,
    How can I set cookie before loading a url on WebEngineView that is created in qml code, can I inherit from something like WebEngineViewItem to create my customized WebEngineView?
    the WebEngineView widget has a page() method that return page and then I can get profile and then the cookieStore but I didn't find any way for qml code.

    1 Reply Last reply
    0
    • HojjatJafaryH Offline
      HojjatJafaryH Offline
      HojjatJafary
      wrote on last edited by
      #2

      Seems this is OK,

      QQuickWebEngineProfile* defaultProfile = QQuickWebEngineProfile::defaultProfile();
      QWebEngineCookieStore *cookieStore = defaultProfile->cookieStore();
      
      QNetworkCookie cookie;
      cookie.setDomain("domain.com");
      cookie.setName("devmode");
      cookie.setValue("true");
      
      cookieStore->setCookie(cookie);
      

      You can also pass the profile property of the WebEngineView from Qml to C++ and do same.
      There is no page method for Qml WebEngineView.

      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