如何使用 HTML/CSS UI 构建本机 C++ 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17517249/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to build native C++ apps with HTML/CSS UI?
提问by ranisalt
Is it possible to develop a C++ program while using HTML and CSS for the user interface? I know about programming with Javascript using a Webkit container, but I am really interested in C++ development.
是否可以在将 HTML 和 CSS 用于用户界面的同时开发 C++ 程序?我知道使用 Webkit 容器使用 Javascript 进行编程,但我对 C++ 开发非常感兴趣。
I felt in love with C# WPF when I developed under Windows, but now I moved to Linux and I haven't found a good tool for using markup for interfaces. For this, I would like to mix HTML and CSS, which are very lightweight and easy to use, with C++ code, with something like WPF.
我在 Windows 下开发时就爱上了 C# WPF,但现在我转向了 Linux,我还没有找到一个很好的工具来使用界面标记。为此,我想将非常轻量级且易于使用的 HTML 和 CSS 与 C++ 代码以及 WPF 之类的东西混合使用。
Oh, one more thing: I'm looking for desktop development, not web.
哦,还有一件事:我正在寻找桌面开发,而不是网络。
采纳答案by ranisalt
Yes, it is possible. What you want is a C++ web framework. You could start by looking at CppCMS—a Free High Performance Web Development Framework (not a CMS) aimed for Rapid Web Application Development.
对的,这是可能的。你想要的是一个 C++ web 框架。您可以从CppCMS开始——一个免费的高性能 Web 开发框架(不是 CMS),旨在快速开发 Web 应用程序。
Edit: After the question has been clarified, I think Awesomiumwould be a good fit for your needs.
编辑:在问题得到澄清后,我认为Awesomium将非常适合您的需求。
You can achieve the same functionality by embedding WebKit (or Gecko) but as far as I know that is exactly what Awesomium does behind the scenes.
您可以通过嵌入 WebKit(或 Gecko)来实现相同的功能,但据我所知,这正是 Awesomium 在幕后所做的。
An alternative is librocket—a C++ interface middleware package designed for game applications. As you can guess from the description it is a good fit for games or real-time applications.
另一种选择是librocket——一个为游戏应用程序设计的 C++ 接口中间件包。正如您从描述中可以猜到的,它非常适合游戏或实时应用程序。
回答by c-smile
Sciteris exactly that - embeddable HTML/CSS engine with C/C++ API. Compact and multi-platform.
Sciter就是这样 - 带有 C/C++ API 的可嵌入 HTML/CSS 引擎。紧凑和多平台。
And check this article.
并检查这篇文章。
Sciter has the same feature set as WPFbut uses HTML/CSS instead of XAML and uses native API.
Sciter 具有与WPF相同的功能集,但使用 HTML/CSS 而不是 XAML 并使用本机 API。
Features out of the box:
开箱即用的功能:
- HTML, CSS, SVG, aPNG (animated PNGs), image sprites,
<plaintext>
- editor with syntax highlighting,<htmlarea>
- WYSIWYG HTML editor,<frame type=pager>
- print preview and HTML/CSS print,- animations,
- HTTP client, REST/JSON client, WebSocket's, DataSockets,
- etc.
- HTML、CSS、SVG、aPNG(动画 PNG)、图像精灵、
<plaintext>
- 带有语法高亮的编辑器,<htmlarea>
- 所见即所得的 HTML 编辑器,<frame type=pager>
- 打印预览和 HTML/CSS 打印,- 动画,
- HTTP 客户端、REST/JSON 客户端、WebSocket's、DataSockets、
- 等等。
The same application with Sciter UI running on Windows, MacOS and Linux from the same sources:
在 Windows、MacOS 和 Linux 上运行来自相同来源的具有 Sciter UI 的相同应用程序:
Disclaimer: I am an author of Sciter Engine.
免责声明:我是 Sciter Engine 的作者。
回答by Vadim Ovchinnikov
You can use Chromium Embedded Frameworkto embed HTML5 content in your app. You'll get might and speed of Chromium and ability to build GUI apps the same way you develop web applications.
您可以使用Chromium Embedded Framework在您的应用中嵌入 HTML5 内容。您将获得 Chromium 的强大功能和速度,以及以与开发 Web 应用程序相同的方式构建 GUI 应用程序的能力。
回答by Johannes
I think Electronwould be a nice addition to the other answers.
我认为Electron将是其他答案的一个很好的补充。
It uses NodeJS to run a Webkit Window. Electron itself is only html/css/js, but you can use any Node Module within your Electron App - including custom, natively compiled C++ code. A possible Module to embed your C++ code would be node-gyp.
它使用 NodeJS 来运行 Webkit 窗口。Electron 本身只是 html/css/js,但你可以在你的 Electron 应用程序中使用任何节点模块——包括自定义的、本地编译的 C++ 代码。嵌入 C++ 代码的可能模块是 node-gyp。
Be aware, however, that this workflow may include a little bit more JS than you would have with the other answers.
但是请注意,与其他答案相比,此工作流程可能包含更多的 JS。
My favourite text editor, Atom, was made with Electron.
我最喜欢的文本编辑器Atom是用 Electron 制作的。
回答by tomer zeitune
As of 2019 I suggest you'll check out the Ultralight HTML UI Engine
Not Open Source, Available for C++. OpenGL and DirectX rendering supported.
截至 2019 年,我建议您查看Ultralight HTML UI Engine
Not Open Source, Available for C++。支持 OpenGL 和 DirectX 渲染。
Ultralight is the lighter, faster option to integrate HTML UI in your C++ app.
Ultralight 是在 C++ 应用程序中集成 HTML UI 的更轻、更快的选择。
It's made by the creator of Awesomium, who unfortunately decided to delete Awesomium. This is what we got now.
它是由 Awesomium 的创建者制作的,不幸的是,他决定删除 Awesomium。这就是我们现在得到的。
If you need something more heavy weight rather than lightweight I recommend taking a look at CEF. It's a very powerful (and open source) tool.
如果您需要更重的东西而不是轻量级的,我建议您查看CEF。这是一个非常强大(和开源)的工具。