首先要写一个继承QWebEngineView的类

头文件:

#ifndef WEBBROWSER_H
#define WEBBROWSER_H #include <QWebEngineView>
#include <QWidget> namespace netsharp { class WebBrowser : public QWebEngineView
{
Q_OBJECT public:
explicit WebBrowser(QWidget* parent = Q_NULLPTR); protected:
/**
* @brief createWindow 在鼠标左键点击的时候会触发这个方法
* @param type
* @return
*/
QWebEngineView *createWindow(QWebEnginePage::WebWindowType type); private :
}; } #endif // WEBBROWSER_H

实现文件:

#include "webbrowser.h"
#include "MainWindow.h"
#include <QWidget>
#include<QMessageBox>
#include<QMainWindow> namespace netsharp { WebBrowser::WebBrowser(QWidget *parent) : QWebEngineView(parent)
{
} QWebEngineView *WebBrowser::createWindow(QWebEnginePage::WebWindowType type)
{
WebBrowser *webbrowser = new WebBrowser(this); QMainWindow *dialog = new QMainWindow() ;
dialog->setCentralWidget(webbrowser);
dialog->show(); return webbrowser; } }

主窗口调用文件代码(mainwindow.cpp)

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "WebBrowser.h"
#include "QSystemTrayIcon"
#include "QMessageBox"
#include <QTimer>
#include <QUrl> using namespace netsharp; MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{ ui->setupUi(this); this->webbrowser = new WebBrowser(this);
this->webbrowser->load(QUrl("http://beehive.gongsibao.com"));
this->setCentralWidget(this->webbrowser); }

另:

QWebEngineView在QT Creator开发的时候网页加载特别慢,使用release方式即可解决,嗖嗖快

QT-QWebEngineView-createWindow弹出页面解决的更多相关文章

  1. linux下QT程序输出乱码解决方法

    参考文章:http://blog.csdn.net/jiang1013nan/article/details/6667871 http://my.oschina.net/zjlaobusi/blog/ ...

  2. qt 视频播放器错误解决方法

    DirectShowPlayerService::doRender: Unresolved error code 0x80040266 () 当你发布的qmlproject包含QtMultimedia ...

  3. ubuntu16.04下fcitx无法在QT Creator输入中文解决办法

    我的博客新地址:www.liuquanhao.com ------------------------------------------------------ Qt creator无法用fcitx ...

  4. 两个常见Qt编译错误的解决

    作者:朱金灿 来源:http://blog.csdn.net/clever101 如果在电脑上安装了两个Qt版本,在编译一个工程时有可能出现如下的编译错误: ERROR: failed to refr ...

  5. 基于Linux(中标麒麟)上QT的环境搭建——解决cannot find lGL的问题

    接上一篇,QT在中标麒麟环境安装完成后遇到运行报错的问题 一.问题描述: 在中标麒麟上配置好QT的环境后,新建一个工程,不做其他的任何操作,直接运行都会报cannot find lGL的错误.如图所示 ...

  6. fedora 18~20 中Qt 5.2.1 解决连接mysql数据库出现QMYSQL driver not loaded的问题

    QT       += sql //在.pro文件里加入这一句 //包含头文件 #include <QDebug> #include <QSqlQuery> #include  ...

  7. ubuntu18.04安装qt时候的错误解决

    在ubuntu系统下安装好qt5.5后启动qtceator时提示: Qt5.5.1/Tools/QtCreator/lib/qtcreator/plugins/libHelp.so: 无法加载库Qt5 ...

  8. Mac下QT错误,Xcode配置解决办法

    出现错误: Xcode not set up properly. You may need to confirm the license agreement by running / 解决办法如下: ...

  9. Window下Qt Creator启动错误解决方法

    很多电脑现在都是用的是双显卡,高性能的独显和性能比较差但耗电少的集显,在Window10系统下右键点击软件,在"图形处理器"里面可以选择使用什么显卡操作此软件.下面是我在运行Qt ...

随机推荐

  1. ubuntu16.04 安装最新版nodejs

    ubuntu软件仓库中自带的nodejs版本过低 $ apt-cache policy nodejs nodejs: Installed: (none) Candidate: 4.2.6~dfsg-1 ...

  2. 对于使用JDBC连接mysql数据时The server time zone value '¤¤°ê¼Ð·Ç®É¶¡'...的异常问题解决。

    相信很多小伙伴和我一样遇到了这类问题,在使用JDBC连接mysql数据库的时候发生SQLException如下所示的异常情况! java.sql.SQLException: The server ti ...

  3. 4th Dec 2018

    两个人都觉得自己没错,或者对方都把错误归结于另外一方,总会盯着对方的不足,无限放大:谁都不肯先放下兵器,亦或害怕自己放下了兵器,对方又拿起了盾.这就好像双方在同一时间拉扯一根皮筋,拉扯的越长,张力越大 ...

  4. 205. jetcache:你需要知道的小技巧

    [视频&交流平台] àSpringBoot视频:http://t.cn/R3QepWG à SpringCloud视频:http://t.cn/R3QeRZc à Spring Boot源码: ...

  5. Jquery对表格的一些简单应用 查询&即时匹配&点击高亮等

    代码如下(暂时没有用原生js实现): <!DOCTYPE html> <html lang="en"> <head> <meta char ...

  6. SpringCloud系列二:Restful 基础架构(搭建项目环境、创建 Dept 微服务、客户端调用微服务)

    1.概念:Restful 基础架构 2.具体内容 对于 Rest 基础架构实现处理是 SpringCloud 核心所在,其基本操作形式在 SpringBoot 之中已经有了明确的讲解,那么本次为 了清 ...

  7. C# 调用程序集方法

    加载程序集 (Assembly类) 使用 Assembly 类可以加载程序集.浏览程序集的元数据和构成部分.发现程序集中包含的类型以及创建这些类型的实例 // 加载该路径的程序集 Assembly a ...

  8. 早期自学jQuery-一入门

    本节目录: ----------①安装使用 ----------②语法 ----------③文档就绪函数 ----------④选择器 一.安装使用(特别注意jQuery应当位于<head&g ...

  9. 解决no module named ipykernel_launcher

    解决no module named ipykernel_launcher 最近开hydrogen的时候,提示no module named ipykernel_launcher. 记得以前解决过这个问 ...

  10. virsh命令详解

    1.简介: virsh 有命令模式和交互模式如果直接在vrish后面添加参数是命令模式,如果直接写virsh,就会进入交互模式. 2.命令模式: virsh list    列出所有的虚拟机,虚拟机的 ...