用 C++ 运行 QtWebEngine [英] Running QtWebEngine with C++

查看:75
本文介绍了用 C++ 运行 QtWebEngine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是第一次尝试 Qt,想创建一个非常基本的应用程序来加载网站.我想使用 Qt WebEngine.

I'm trying out Qt for the first time and want to create a very basic application which loads a website. I want to use Qt WebEngine.

这是我的 helloworld.pro:

This is my helloworld.pro:

TEMPLATE = app
TARGET = hello
DEPENDPATH += .
INCLUDEPATH += .

QT += webenginewidgets

SOURCES += hello.cpp

这是我的 hello.cpp

And this is my hello.cpp

#include <QApplication>
#include <QtWebEngineWidgets/QtWebEngineWidgets>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWebEngineView *view = new QWebEngineView(parent);
    view->load(QUrl("http://qt-project.org/"));
    view->show();

    return app.exec();
}

尝试编译时出现错误:

Project ERROR: Unknown module(s) in QT: QWebEngineView
Project ERROR: Unknown module(s) in QT: webenginewidgets

我想我知道它找不到模块,但查看 qt 文档似乎是包含它们的正确方法.

I guess I know that it cannot find the modules, but looking into the qt-documentation it seems as the right way to include them.

我在 Qt 5.5.0 上运行 QtCreator 3.4.2.

I'm running QtCreator 3.4.2 on Qt 5.5.0.

推荐答案

目前似乎只支持少数编译器:

It looks like it is only supported on a few compilers right now:

http://wiki.qt.io/QtWebEngine#Q:_On_which_platforms_will_it_run.3F

尝试使用其中一种配置进行构建,它应该可以工作.

Try building with one of those configured, and it should work.

我的猜测是,它所构建的 Chromium 项目基本上非常复杂,有很多依赖项,而且 QtWebEngine 还没有被其他编译器向后移植.

My guess is that basically the Chromium project it is built on is very complex with lots of dependencies and QtWebEngine hasn't been backported other compilers yet.

QtWebKit 在大多数情况下仍应受支持,但 QtWebEngine 是前进的方向.

QtWebKit should still be supported most of the time, but QtWebEngine is where things are headed.

希望有所帮助.

这篇关于用 C++ 运行 QtWebEngine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆