Qt+C++自建网页浏览器-Chrome最新内核基础上搭建-改进版本

 程序示例精选

Qt+C++自建网页浏览器-Chrome blink最新内核基础上搭建-改进版本

如需安装运行环境或远程调试,见文章底部个人QQ名片,由专业技术人员远程协助!

前言

这篇博客针对<<Qt+C++自建网页浏览器-Chrome最新内核基础上搭建-改进版本>>编写代码,代码整洁,规则,易读。 学习与应用推荐首选。

功能:网页浏览器,带视频播放,多选项卡,前进,后退功能。


文章目录

一、所需工具软件

二、使用步骤

1. 引入库

2. 窗体界面

3. 运行结果

三、在线协助

一、所需工具软件

1. VS, Qt

2. Win10, Win11

二、使用步骤

1.引入库

代码如下(示例):


#include "QUrl"
#include <iostream>
#include<string>
#include<QKeyEvent>
#include<QFontDatabase>
#include<QWebEngineSettings>
#include<QWebEngineCookieStore>

2.窗体界面

代码如下(示例):


QT_BEGIN_NAMESPACE

class Ui_MainWindowClass
{
public:
    QAction *actionaa;
    QWidget *centralWidget;
    QGridLayout *gridLayout_3;
    QFrame *frame_2;
    QGridLayout *gridLayout_2;
    QComboBox *comboBox;
    QHBoxLayout *horizontalLayout;
    QPushButton *pushButton_4;
    QPushButton *pushButton_3;
    QPushButton *pushButton_2;
    QLineEdit *lineEdit;
    QPushButton *pushButton;
    QPushButton *pushButton_5;
    QPushButton *pushButton_6;
    QSpacerItem *horizontalSpacer;
    QSpacerItem *horizontalSpacer_2;
    QLabel *label;
    QFrame *frame;
    QGridLayout *gridLayout;
    QWebEngineView *webEngineView;
    QMenuBar *menuBar;
    QToolBar *mainToolBar;
    QStatusBar *statusBar;

    void setupUi(QMainWindow *MainWindowClass)
    {
        if (MainWindowClass->objectName().isEmpty())
            MainWindowClass->setObjectName(QString::fromUtf8("MainWindowClass"));
        MainWindowClass->resize(716, 400);
        actionaa = new QAction(MainWindowClass);
        actionaa->setObjectName(QString::fromUtf8("actionaa"));
        QIcon icon;
        QString iconThemeName = QString::fromUtf8("dfds");
        if (QIcon::hasThemeIcon(iconThemeName)) {
            icon = QIcon::fromTheme(iconThemeName);
        } else {
            icon.addFile(QString::fromUtf8(":/MainWindow/png/\346\211\223\345\274\200\346\226\207\344\273\266\345\244\271-\347\272\242\350\211\262.png"), QSize(), QIcon::Normal, QIcon::Off);
        }
        actionaa->setIcon(icon);
        centralWidget = new QWidget(MainWindowClass);
        centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
        gridLayout_3 = new QGridLayout(centralWidget);
        gridLayout_3->setSpacing(6);
        gridLayout_3->setContentsMargins(11, 11, 11, 11);
        gridLayout_3->setObjectName(QString::fromUtf8("gridLayout_3"));
        frame_2 = new QFrame(centralWidget);
        frame_2->setObjectName(QString::fromUtf8("frame_2"));
        QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
        sizePolicy.setHorizontalStretch(1);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(frame_2->sizePolicy().hasHeightForWidth());
        frame_2->setSizePolicy(sizePolicy);
        QFont font;
        font.setFamily(QString::fromUtf8("3ds"));
        font.setPointSize(16);
        frame_2->setFont(font);
        frame_2->setFrameShape(QFrame::Box);
        frame_2->setFrameShadow(QFrame::Raised);
        gridLayout_2 = new QGridLayout(frame_2);
        gridLayout_2->setSpacing(6);
        gridLayout_2->setContentsMargins(11, 11, 11, 11);
        gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
        comboBox = new QComboBox(frame_2);
        comboBox->addItem(QString());
        comboBox->addItem(QString());
        comboBox->addItem(QString());
        comboBox->setObjectName(QString::fromUtf8("comboBox"));
        QFont font1;
        font1.setFamily(QString::fromUtf8("\345\276\256\350\275\257\351\233\205\351\273\221"));
        font1.setPointSize(12);
        comboBox->setFont(font1);

        gridLayout_2->addWidget(comboBox, 0, 2, 1, 1);

        horizontalLayout = new QHBoxLayout();
        horizontalLayout->setSpacing(6);
        horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
        pushButton_4 = new QPushButton(frame_2);
        pushButton_4->setObjectName(QString::fromUtf8("pushButton_4"));

        horizontalLayout->addWidget(pushButton_4);

        pushButton_3 = new QPushButton(frame_2);
        pushButton_3->setObjectName(QString::fromUtf8("pushButton_3"));

        horizontalLayout->addWidget(pushButton_3);

        pushButton_2 = new QPushButton(frame_2);
        pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));

        horizontalLayout->addWidget(pushButton_2);

        lineEdit = new QLineEdit(frame_2);
        lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
        QFont font2;
        font2.setFamily(QString::fromUtf8("\345\276\256\350\275\257\351\233\205\351\273\221"));
        lineEdit->setFont(font2);

        horizontalLayout->addWidget(lineEdit);

        pushButton = new QPushButton(frame_2);
        pushButton->setObjectName(QString::fromUtf8("pushButton"));
        QFont font3;
        font3.setFamily(QString::fromUtf8("\345\276\256\350\275\257\351\233\205\351\273\221"));
        font3.setPointSize(16);
        pushButton->setFont(font3);

        horizontalLayout->addWidget(pushButton);

        pushButton_5 = new QPushButton(frame_2);
        pushButton_5->setObjectName(QString::fromUtf8("pushButton_5"));
        pushButton_5->setFont(font2);

        horizontalLayout->addWidget(pushButton_5);

        pushButton_6 = new QPushButton(frame_2);
        pushButton_6->setObjectName(QString::fromUtf8("pushButton_6"));
        pushButton_6->setFont(font2);

        horizontalLayout->addWidget(pushButton_6);

        horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

        horizontalLayout->addItem(horizontalSpacer);


        gridLayout_2->addLayout(horizontalLayout, 0, 0, 1, 1);

        horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

        gridLayout_2->addItem(horizontalSpacer_2, 0, 1, 1, 1);

        label = new QLabel(frame_2);
        label->setObjectName(QString::fromUtf8("label"));
        label->setFont(font2);

        gridLayout_2->addWidget(label, 0, 3, 1, 1);


        gridLayout_3->addWidget(frame_2, 0, 0, 1, 1);

        frame = new QFrame(centralWidget);
        frame->setObjectName(QString::fromUtf8("frame"));
        QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Preferred);
        sizePolicy1.setHorizontalStretch(0);
        sizePolicy1.setVerticalStretch(6);
        sizePolicy1.setHeightForWidth(frame->sizePolicy().hasHeightForWidth());
        frame->setSizePolicy(sizePolicy1);
        frame->setFrameShape(QFrame::Box);
        frame->setFrameShadow(QFrame::Raised);
        gridLayout = new QGridLayout(frame);
        gridLayout->setSpacing(5);
        gridLayout->setContentsMargins(11, 11, 11, 11);
        gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
        gridLayout->setContentsMargins(0, 0, 0, 0);
        webEngineView = new QWebEngineView(frame);
        webEngineView->setObjectName(QString::fromUtf8("webEngineView"));
        webEngineView->setUrl(QUrl(QString::fromUtf8("about:blank")));

        gridLayout->addWidget(webEngineView, 0, 0, 1, 1);


        gridLayout_3->addWidget(frame, 1, 0, 1, 1);

        mainToolBar->addAction(actionaa);
        mainToolBar->addSeparator();

        retranslateUi(MainWindowClass);

        QMetaObject::connectSlotsByName(MainWindowClass);
    } // setupUi

    void retranslateUi(QMainWindow *MainWindowClass)
    {
        MainWindowClass->setWindowTitle(QCoreApplication::translate("MainWindowClass", "MainWindow", nullptr));
        actionaa->setText(QCoreApplication::translate("MainWindowClass", "aa", nullptr));
#if QT_CONFIG(shortcut)
        actionaa->setShortcut(QCoreApplication::translate("MainWindowClass", "Ctrl+O", nullptr));
#endif // QT_CONFIG(shortcut)
        comboBox->setItemText(0, QString());
        comboBox->setItemText(1, QCoreApplication::translate("MainWindowClass", "www.baidu.com", nullptr));
        comboBox->setItemText(2, QCoreApplication::translate("MainWindowClass", "www.csdn.net", nullptr));

};

namespace Ui {
    class MainWindowClass: public Ui_MainWindowClass {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_MAINWINDOW_H

3.运行结果如下

三、在线协助:

如需安装运行环境或远程调试,见文章底部个人 QQ 名片,由专业技术人员远程协助!
1)远程安装运行环境,代码调试
2)Qt, C++, Python入门指导
3)界面美化
4)软件制作

 当前文章连接:https://blog.csdn.net/alicema1111/article/details/132666851

博主推荐文章:python人脸识别统计人数qt窗体-CSDN博客

博主推荐文章:Python Yolov5火焰烟雾识别源码分享-CSDN博客

                         Python OpenCV识别行人入口进出人数统计_python识别人数-CSDN博客

个人博客主页:alicema1111的博客_CSDN博客-Python,C++,网页领域博主

博主所有文章点这里:月光码头_Python,C++,C++ VTK-CSDN博客

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
迷你仪表盘是一种自定义控件,主要用于显示简单的数据指示或状态显示。在Qt/C++中编写自定义迷你仪表盘需要以下步骤: 1. 创建一个新的自定义控件类,可以继承QWidget或QLabel。在类的构造函数中初始化一些基本属性,例如仪表盘的大小、颜色、范围等。 2. 重写paintEvent函数,该函数用于绘制仪表盘的外观。在paintEvent函数中,可以使用QPainter绘制各种图形元素,例如圆形、刻度线、指针等。可以根据数据范围和当前值来动态改变指针的位置或角度。 3. 定义一些公有的函数或信号槽,用于设置或更新仪表盘的值。例如,可以定义一个setValue函数用于设置当前值,并在函数内部调用update函数来触发重绘事件。 4. 在主窗口或其他需要使用仪表盘的地方,实例化自定义的迷你仪表盘控件,并设置一些属性,例如位置、大小、初始值等。还可以通过设置样式表来对仪表盘进行外观的自定义。 5. 根据需要,可以添加一些交互功能。例如,可以响应鼠标点击事件,以实现互动操作,例如点击指针可以通过setValue函数来设置对应的值。 编写自定义控件需要一定的Qt/C++编程基础和绘图知识,掌握了基本的绘图函数和事件处理机制后,可以根据需求进行扩展和优化。同时,为了提高代码的可重用性和可维护性,可以将控件的逻辑和外观分离,采用MVC设计模式或其他架构模式进行开发

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

荷塘月色2

您的鼓励将是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值