<tfoot id='Qsrmt'></tfoot>
        <i id='Qsrmt'><tr id='Qsrmt'><dt id='Qsrmt'><q id='Qsrmt'><span id='Qsrmt'><b id='Qsrmt'><form id='Qsrmt'><ins id='Qsrmt'></ins><ul id='Qsrmt'></ul><sub id='Qsrmt'></sub></form><legend id='Qsrmt'></legend><bdo id='Qsrmt'><pre id='Qsrmt'><center id='Qsrmt'></center></pre></bdo></b><th id='Qsrmt'></th></span></q></dt></tr></i><div id='Qsrmt'><tfoot id='Qsrmt'></tfoot><dl id='Qsrmt'><fieldset id='Qsrmt'></fieldset></dl></div>
          <bdo id='Qsrmt'></bdo><ul id='Qsrmt'></ul>

      1. <legend id='Qsrmt'><style id='Qsrmt'><dir id='Qsrmt'><q id='Qsrmt'></q></dir></style></legend>

        <small id='Qsrmt'></small><noframes id='Qsrmt'>

        如何将 QWebEngineProfile 设置为 QWebEngineView

        时间:2023-08-05
        <i id='XPDGY'><tr id='XPDGY'><dt id='XPDGY'><q id='XPDGY'><span id='XPDGY'><b id='XPDGY'><form id='XPDGY'><ins id='XPDGY'></ins><ul id='XPDGY'></ul><sub id='XPDGY'></sub></form><legend id='XPDGY'></legend><bdo id='XPDGY'><pre id='XPDGY'><center id='XPDGY'></center></pre></bdo></b><th id='XPDGY'></th></span></q></dt></tr></i><div id='XPDGY'><tfoot id='XPDGY'></tfoot><dl id='XPDGY'><fieldset id='XPDGY'></fieldset></dl></div>
        <legend id='XPDGY'><style id='XPDGY'><dir id='XPDGY'><q id='XPDGY'></q></dir></style></legend>

          • <bdo id='XPDGY'></bdo><ul id='XPDGY'></ul>

            <small id='XPDGY'></small><noframes id='XPDGY'>

              <tbody id='XPDGY'></tbody>
                <tfoot id='XPDGY'></tfoot>
                  本文介绍了如何将 QWebEngineProfile 设置为 QWebEngineView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想为不同的 QWebEngineViews 设置不同的 QWebEngineProfiles,这意味着每个视图都有自己的 cookie 存储.我找不到任何有关它的文档,因此将不胜感激所有帮助.任何将独立 cookie 存储设置为独立 web 视图的其他方法的任何建议也将有所帮助.干杯.

                  I want to set different QWebEngineProfiles to different QWebEngineViews meaning each view will have its own cookie store. I cant find any documentation on it therefore all help would be greatly appreciated. Any suggestion of another method of setting independent cookie stores to independent webviews will also help. Cheers.

                  代码如下(此处连接信号格式不正确,但请放心,在真实代码中是正确的):

                  Code is below (connecting the signal did not format properly here but rest assured it is correct in the real code):

                  from PyQt5.QtCore import *
                  from PyQt5.QtWidgets import * 
                  from PyQt5.QtGui import *
                  from PyQt5.QtWebEngineWidgets import *
                  import sys
                  
                  class MainWindow(QMainWindow):
                  
                      def __init__(self, *args, **kwargs):
                          super(MainWindow, self).__init__(*args,**kwargs)
                          self.browser={}
                          self.cookiestore={}
                          self.page={}
                          No = input("No: ")
                          for i in range(int(No)):
                              self.browser[str(i)] = QWebEngineView()
                              storagename = str(i)
                              self.cookiestore[str(i)] = QWebEngineProfile(storagename, self.browser[str(i)])
                              self.page[str(i)] = QWebEnginePage(self.cookiestore[str(i)], self.browser[str(i)])
                              self.browser[str(i)].setPage(self.page[str(i)])
                              self.browser[str(i)].load(QUrl("https://www.google.com"))
                        self.browser[str(i)].loadFinished.connect(lambda:self._loaded(str(i)))
                  
                      def _loaded(self, No):
                          self.browser[No].page().toHtml(self._callable)
                      def _callable(self, data):
                          self.html = data
                          if "" in self.html:
                              print("Done")
                          else:
                              print("wait")
                  
                  app = QApplication(sys.argv)
                  window = MainWindow()
                  app.exec_()
                  

                  推荐答案

                  如果你想建立一个 QWebEngineProfile 到一个 QWebEngineView 你必须通过一个 QWebEnginePage 如下所示:

                  If you want to establish a QWebEngineProfile to a QWebEngineView you must do it through a QWebEnginePage as I show below:

                  webview = QWebEngineView()
                  profile = QWebEngineProfile("somestorage", webview)
                  webpage = QWebEnginePage(profile, webview)
                  webview.setPage(webpage)
                  

                  例子:

                  from PyQt5.QtCore import QUrl
                  from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile, QWebEnginePage
                  from PyQt5.QtWidgets import QApplication
                  
                  if __name__ == '__main__':
                      import sys
                  
                      app = QApplication(sys.argv)
                      views = []
                      for i in range(5):
                          webview = QWebEngineView()
                          profile = QWebEngineProfile(f"storage-{i}", webview)
                          webpage = QWebEnginePage(profile, webview)
                          webview.setPage(webpage)
                          webview.load(QUrl("https://stackoverflow.com/questions/48142341/how-to-set-a-qwebengineprofile-to-a-qwebengineview"))
                          webview.show()
                          views.append(webview)
                      sys.exit(app.exec_())
                  

                  这篇关于如何将 QWebEngineProfile 设置为 QWebEngineView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PyQt5标签被切断 下一篇:'pyuic5' 未被识别为内部或外部命令

                  相关文章

                  最新文章

                      <bdo id='2J9bV'></bdo><ul id='2J9bV'></ul>
                  1. <i id='2J9bV'><tr id='2J9bV'><dt id='2J9bV'><q id='2J9bV'><span id='2J9bV'><b id='2J9bV'><form id='2J9bV'><ins id='2J9bV'></ins><ul id='2J9bV'></ul><sub id='2J9bV'></sub></form><legend id='2J9bV'></legend><bdo id='2J9bV'><pre id='2J9bV'><center id='2J9bV'></center></pre></bdo></b><th id='2J9bV'></th></span></q></dt></tr></i><div id='2J9bV'><tfoot id='2J9bV'></tfoot><dl id='2J9bV'><fieldset id='2J9bV'></fieldset></dl></div>

                    <small id='2J9bV'></small><noframes id='2J9bV'>

                      <legend id='2J9bV'><style id='2J9bV'><dir id='2J9bV'><q id='2J9bV'></q></dir></style></legend>

                      <tfoot id='2J9bV'></tfoot>