久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

      • <bdo id='VPYHM'></bdo><ul id='VPYHM'></ul>
      <i id='VPYHM'><tr id='VPYHM'><dt id='VPYHM'><q id='VPYHM'><span id='VPYHM'><b id='VPYHM'><form id='VPYHM'><ins id='VPYHM'></ins><ul id='VPYHM'></ul><sub id='VPYHM'></sub></form><legend id='VPYHM'></legend><bdo id='VPYHM'><pre id='VPYHM'><center id='VPYHM'></center></pre></bdo></b><th id='VPYHM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VPYHM'><tfoot id='VPYHM'></tfoot><dl id='VPYHM'><fieldset id='VPYHM'></fieldset></dl></div>
    1. <tfoot id='VPYHM'></tfoot>

        <legend id='VPYHM'><style id='VPYHM'><dir id='VPYHM'><q id='VPYHM'></q></dir></style></legend>

        QWebEngineView 中的 Qt 事件傳播

        Qt Event Propagation in QWebEngineView(QWebEngineView 中的 Qt 事件傳播)
        <legend id='i2sMG'><style id='i2sMG'><dir id='i2sMG'><q id='i2sMG'></q></dir></style></legend>
        • <bdo id='i2sMG'></bdo><ul id='i2sMG'></ul>

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

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

                    <tbody id='i2sMG'></tbody>
                1. 本文介紹了QWebEngineView 中的 Qt 事件傳播的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個名為 generate_input_event 的函數.我正在嘗試使用此功能來模擬 QWebEngineView 中的按鍵.

                  I have a function named generate_input_event. I'm trying to use this function to simulate a keypress within a QWebEngineView.

                  def generate_input_event(window_id, key_code, modifiers, low_level_data, x, y):
                      modifiers_flag = create_modifiers_flag(modifiers)
                      logging.info("generate input, window: {} code: {}, modifiers {}".format(
                          window_id, key_code, modifiers_flag))
                      event = QKeyEvent(QEvent.KeyPress, key_code, modifiers_flag)
                      event.artificial = True
                      event_window = window.get_window(window_id)
                      QCoreApplication.sendEvent(event_window.qtwindow, event)
                  

                  每當我運行我的程序并在我的 QWebEngineView 中突出顯示一個輸入字段,并調用 generate_input_event 時,預計它會將該字母輸入到輸入字段中.

                  Whenever I run my program and highlight an input field within my QWebEngineView, and invoke generate_input_event it is expected that it will type that letter into the input field.

                  我還設置了一個事件過濾器來捕獲所有按鍵,除了我人工生成的按鍵.

                  I also set-up an event filter to capture everything all key presses EXCEPT for my artificially generated ones.

                  class EventFilter(QWidget):
                      def __init__(self, parent=None):
                          super(EventFilter, self).__init__(parent)
                          qApp.installEventFilter(self)
                  
                      def eventFilter(self, obj, event):
                          if (event.type() == QEvent.KeyPress and hasattr(event, 'artificial')):
                              logging.info("artificial event")
                              return False. # send to widget
                          elif (event.type() == QEvent.KeyPress and not is_modifier(event.key())):
                              modifiers = create_modifiers_list(event.modifiers())
                              key_string = create_key_string(event)
                              key_code = event.key()
                              logging.info("send code: {} string: {} modifiers {}".format(
                                  key_code, key_string, modifiers))
                              return True. # do not forward to widgets
                          return False
                  

                  但是,當我實際運行我的代碼時,我得到以下輸出:

                  However when I actually run my code, this is the following output I get:

                  INFO:root:send code: 65 string: a modifiers ['']
                  INFO:root:generate input, window: 1 code: 65, modifiers <PyQt5.QtCore.Qt.KeyboardModifiers object at 0x106a4ea58>
                  INFO:root:artificial event
                  

                  輸出看起來是正確的,但是,QWebEngineView 的輸入字段實際上從來沒有得到一個由 generate_input_event 人為生成的字母.

                  The output looks correct, HOWEVER, the input field of the QWebEngineView never actually gets a letter that was artificially generated by generate_input_event.

                  附:如果您出于上下文原因希望查看整個文件/項目,請在此處查看此分支/文件:https://github.com/atlas-engineer/next/blob/generate_events/ports/pyqt-webengine/utility.py

                  P.S. Should you wish to see the whole of the file/project for reasons of context, please look at this branch/file here: https://github.com/atlas-engineer/next/blob/generate_events/ports/pyqt-webengine/utility.py

                  推薦答案

                  可以通過以下最小示例演示發布和偵聽 QWebengineview 事件的正確方法:

                  The correct way to post and listen to events for a QWebengineview can be demonstrated with the following minimal example:

                  
                  from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
                  from PyQt5.QtCore import Qt
                  
                  
                  class ForwardKeyEvent(QtCore.QObject):
                      def __init__(self, sender, receiver, parent=None):
                          super(ForwardKeyEvent, self).__init__(parent)
                          self.m_sender = sender
                          self.m_receiver = receiver
                          self.m_sender.installEventFilter(self)
                  
                      def eventFilter(self, obj, event):
                          if self.m_sender is obj and event.type() == QtCore.QEvent.KeyPress:
                              new_event = QtGui.QKeyEvent(
                                  QtCore.QEvent.KeyPress,
                                  65,
                                  Qt.KeyboardModifiers(),
                                  "a",
                              )
                              new_event.artificial = True
                              QtCore.QCoreApplication.postEvent(self.m_receiver.focusProxy(), new_event)
                              return True
                          return False
                  
                  
                  if __name__ == "__main__":
                      import sys
                      app = QtWidgets.QApplication(sys.argv)
                      lineedit = QtWidgets.QLineEdit()
                      lineedit.show()
                      view = QtWebEngineWidgets.QWebEngineView()
                      view.resize(640, 480)
                      view.show()
                      view.load(QtCore.QUrl("https://www.google.com/"))
                      # RenderWidgetHostViewQtDelegateWidget is created after loading a page
                      # so you must access it after load() or setHtml().
                      fe = ForwardKeyEvent(lineedit, view)
                      sys.exit(app.exec_())
                  

                  這篇關于QWebEngineView 中的 Qt 事件傳播的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                  <i id='qtLC8'><tr id='qtLC8'><dt id='qtLC8'><q id='qtLC8'><span id='qtLC8'><b id='qtLC8'><form id='qtLC8'><ins id='qtLC8'></ins><ul id='qtLC8'></ul><sub id='qtLC8'></sub></form><legend id='qtLC8'></legend><bdo id='qtLC8'><pre id='qtLC8'><center id='qtLC8'></center></pre></bdo></b><th id='qtLC8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qtLC8'><tfoot id='qtLC8'></tfoot><dl id='qtLC8'><fieldset id='qtLC8'></fieldset></dl></div>
                    <bdo id='qtLC8'></bdo><ul id='qtLC8'></ul>

                        <tbody id='qtLC8'></tbody>

                        1. <small id='qtLC8'></small><noframes id='qtLC8'>

                            <legend id='qtLC8'><style id='qtLC8'><dir id='qtLC8'><q id='qtLC8'></q></dir></style></legend><tfoot id='qtLC8'></tfoot>
                            主站蜘蛛池模板: 久久精品一 | 亚洲成人免费视频在线观看 | 久久亚洲综合 | 中文字幕精品一区二区三区精品 | 男人天堂视频在线观看 | 久久成人18免费网站 | 日本电影一区二区 | 国产免费一二三区 | 黑人巨大精品欧美一区二区免费 | 国产精品国产三级国产aⅴ原创 | 99这里只有精品 | 中文字幕的av | 色伊人 | 欧美在线一二三 | 粉嫩国产精品一区二区在线观看 | 欧美日韩免费在线 | 99re国产精品 | 成人免费在线播放视频 | av中文字幕在线 | 亚洲三级在线观看 | 国产精品高潮呻吟久久 | 99久久国产 | 一区二区三区中文字幕 | 香蕉视频一区二区 | 欧美激情国产日韩精品一区18 | 久久久久久国产精品久久 | 久久99精品久久久久久青青日本 | 一级毛片在线播放 | 超碰97人人人人人蜜桃 | 精品影视 | 一区二区三区精品视频 | 亚洲看片 | 99久久久无码国产精品 | 97久久精品午夜一区二区 | av先锋资源| www.国产精品| 狠狠亚洲| 欧美日韩在线精品 | 免费国产视频 | 日本精品一区二区三区四区 | 亚洲网视频 |