code: def contextMenuEvent(self, event):
          
  
          context_menu = QMenu(self)
  
          # add select all
          action_select_all = self.page().action(
              QtWebKitWidgets.QWebPage.SelectAll
          )
          action_select_all.setEnabled(not self.page_to_text() == '')
          context_menu.addAction(action_select_all)
  
          # add copy
          action_copy = self.page().action(QtWebKitWidgets.QWebPage.Copy)
          if qt_at_least('4.8.0'):
              action_copy.setEnabled(not self.selectedHtml() == '')
          else:
              action_copy.setEnabled(not self.selectedText() == '')
          context_menu.addAction(action_copy)
  
          # add show in browser
          action_page_to_html_file = QAction(
              self.tr('Open in web browser'), None)
          # noinspection PyUnresolvedReferences
          action_page_to_html_file.triggered.connect(
              self.open_current_in_browser)
          context_menu.addAction(action_page_to_html_file)
  
          # Add the PDF export menu
          context_menu.addAction(self.action_print_to_pdf)
  
          # add load report
          context_menu.addAction(self.action_show_report)
  
          # add load log
          context_menu.addAction(self.action_show_log)
  
          # add view source if in dev mode
          if self.dev_mode:
              action_copy = self.page().action(
                  QtWebKitWidgets.QWebPage.InspectElement
              )
              action_copy.setEnabled(True)
              context_menu.addAction(action_copy)
  
              # add view to_text if in dev mode
              action_page_to_stdout = QAction(self.tr('log pageToText'),
                                              None)
              # noinspection PyUnresolvedReferences
              action_page_to_stdout.triggered.connect(self.page_to_stdout)
              context_menu.addAction(action_page_to_stdout)
  
          # show the menu
          context_menu.setVisible(True)
          context_menu.exec_(event.globalPos())
docs: Slot automatically called by Qt on right click on the WebView.
  
          :param event: the event that caused the context menu to be called.