qwebview,如何确定此链接是否为新窗口

QWebView,How to determine whether this link is a new window?

本文关键字:新窗口 窗口 是否 何确定 链接 qwebview      更新时间:2023-10-16

代码

  News::News(QWidget *parent) :
   QDialog(parent),
  ui(new Ui::News)
  {
   ui->setupUi(this);
   ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
   connect(ui->webView,SIGNAL(linkClicked(QUrl)),this,SLOT(openUrl(QUrl)));
  }
void News::openUrl(QUrl url){
  if(the new window)
        QDesktopServices::openUrl(url);
  }else{
    ui->webView->load(url);
  }
}

如何判断而不是新的窗口链接函数OpenUrl?我将如何编写此代码,?谢谢!!!

您需要从qwebview继承自己的类,然后重新进来createwindow()方法。http://doc.qt.digia.com/qt/qwebview.html#createwindow