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. C++/QWebEngineView: How to obtain the link clicked by "right-click" + "open in new tab"?
Forum Updated to NodeBB v4.3 + New Features

C++/QWebEngineView: How to obtain the link clicked by "right-click" + "open in new tab"?

Scheduled Pinned Locked Moved Unsolved QtWebEngine
2 Posts 2 Posters 1.1k 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.
  • Navis-RavenN Offline
    Navis-RavenN Offline
    Navis-Raven
    wrote on last edited by
    #1

    In QWebEngineView: How to obtain the link clicked by "right-click" + "open in new tab"?

    Actually I've succeded to catch the action of "open in new tab" (after right-click) by doing this:

    QAction* openInNewTab = view->pageAction(QWebEnginePage::OpenLinkInNewTab);
    connect(openInNewTab, SIGNAL(triggered()), this, SLOT(on_actionNewTab_triggered()));
    

    But in my slot on_actionNewTab_triggered(), I have no possibility to know which url to load. I tried to know if there is something in the data of QAction*

    QVariant va;
    QAction* action = (QAction*)  sender();
    va = action->data();
    

    but the data (va) contains no url !

    1 Reply Last reply
    0
    • M Offline
      M Offline
      miskol
      wrote on last edited by
      #2

      Look at void QWebEnginePage::triggerAction(WebAction action, bool) implementation

      void InContextPreviewView::onOpenLinkInNewWindow( bool )
      {
      const auto & contextMenuData = page()->contextMenuData();
      if( contextMenuData.isValid() && contextMenuData.linkUrl().isValid() )

      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