How to use copy and paste in QWebEngineView
-
QAction* pasteAction = ui->webEngineView->pageAction(QWebEnginePage::Paste); pasteAction->setShortcut(QKeySequence("Ctrl+V")); pasteAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); mUi->webEngineView->addAction(pasteAction);
Is there somethings wrong?It does not work!
-
I have the same problem, but in PyQt 5. Ended up using an alternative solution with an external "keyboard" library that mimics keyboard presses:
if self.page().contextMenuData().isContentEditable() == True: #check if an input field was right-clicked self.menus = QMenu() action1 = QAction("Paste text", self) self.menus.addAction(action1) self.menus.popup(event.globalPos()) action1.triggered.connect(self.paste_into_field)
def paste_into_field(self): keyboard.press_and_release("ctrl+v")