How to build native C++ apps with HTML/CSS UI?

后端 未结 5 1689
没有蜡笔的小新
没有蜡笔的小新 2021-01-29 17:42

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 inter

相关标签:
5条回答
  • 2021-01-29 18:25

    You can use Chromium Embedded Framework to 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.

    0 讨论(0)
  • 2021-01-29 18:32

    I think Electron would be a nice addition to the other answers.

    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.

    Be aware, however, that this workflow may include a little bit more JS than you would have with the other answers.

    My favourite text editor, Atom, was made with Electron.

    0 讨论(0)
  • 2021-01-29 18:33

    Sciter is exactly that - embeddable HTML/CSS engine with C/C++ API. Compact and multi-platform.

    And check this article.

    Sciter has the same feature set as WPF but uses HTML/CSS instead of XAML and uses native 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.

    The same application with Sciter UI running on Windows, MacOS and Linux from the same sources:

    Disclaimer: I am an author of Sciter Engine.

    2021 update: you can also use Sciter.JS that is version of Sciter that uses standard JavaScript (ES2020) script engine.

    0 讨论(0)
  • 2021-01-29 18:33

    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.

    Ultralight is the lighter, faster option to integrate HTML UI in your C++ app.

    It's made by the creator of Awesomium, who unfortunately decided to delete Awesomium. This is what we got now.

    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.

    0 讨论(0)
  • 2021-01-29 18:46

    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.

    Edit: After the question has been clarified, I think Awesomium would be a good fit for your needs.

    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.

    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.

    0 讨论(0)
提交回复
热议问题