C++ 哪个(如果有)实现了 Windows 原生外观:GTK+、wxWidgets、Qt、FLTK?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18980426/
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
Which, if any, achieves Windows native look: GTK+, wxWidgets, Qt, FLTK?
提问by Evgeni Sergeev
I need to write an application that will be visually indistinguishable from something written natively for Windows XP/Vista/7using whatever comes by default with the most modern Visual Studio. But I'm developing using MinGW and Vim (in C++).
我需要编写一个应用程序,该应用程序在视觉上与使用最现代的 Visual Studio 默认提供的任何内容为 Windows XP/Vista/7本地编写的内容没有区别。但我正在使用 MinGW 和 Vim(在 C++ 中)进行开发。
In particular, I want the following controls to be native on the above three versions of Windows: form chrome, buttons, check boxes, menus, combo boxes, progress bars, scrollbars, rich text boxes. This will be enough for me.
特别是,我希望以下控件在上述三个版本的 Windows 上都是原生的:表单镶边、按钮、复选框、菜单、组合框、进度条、滚动条、富文本框。这对我来说就足够了。
I know that if you load GdiPlus and other things like riched32.dll
as needed, and use Windows API to instantiate controls, then the OS will substitute its version of GdiPlus or other library, so it will look like XP style controls on XP, Vista on Vista, etc.
我知道如果你riched32.dll
根据需要加载 GdiPlus 和其他类似的东西,并使用 Windows API 来实例化控件,那么操作系统将替换其版本的 GdiPlus 或其他库,所以它在 XP 上看起来像 XP 风格的控件,在 Vista 上看起来像 Vista,等等。
But I don't want to use plain Windows API, because even retrieving the default font takes half a page of code, and similar stories whatever I want to do. So I'd like to use a toolkit.
但我不想使用普通的 Windows API,因为即使检索默认字体也需要半页代码,无论我想做什么,都会有类似的故事。所以我想使用一个工具包。
wxWidgets, Qt, GTK+, FLTKseem like the most widely used. But they are all cross-platform. I've used cross-platform applications, and many of them have foreign GUI controls (I call them widgets). So my question is: which of these toolkits can be made to produce true native-looking UI controls listed above, appearing correctly on the three versions of MSWin listed above?
wxWidgets、Qt、GTK+、FLTK似乎是使用最广泛的。但它们都是跨平台的。我使用过跨平台应用程序,其中很多都有外部 GUI 控件(我称之为小部件)。所以我的问题是:这些工具包中的哪一个可以用来生成上面列出的真正具有原生外观的 UI 控件,并在上面列出的三个 MSWin 版本上正确显示?
I've typed each of them +" windows" into Google Images, but it's hard to tell, except that FLTK probably can't do it. Many of you must know the answer off the top of your head...
我已经在 Google 图片中输入了每个 +"windows",但很难说,除了 FLTK 可能无法做到。你们中的许多人肯定已经知道答案了……
采纳答案by liberforce
I won't talk about FLTK as I don't know it.
我不会谈论 FLTK,因为我不知道。
- wxWidgets uses the native toolkit of the platform, (GTK on Linux, Win32 GUI API on Windows, Cocoa on MacOS X).
- GTK uses a theming API to fake the look and feel of the platform (custom theming engine on GTK2, CSS-based engine on GTK3).
- Qt uses stylesto fake the look and feel of the platform.
- wxWidgets 使用平台的原生工具包(Linux 上的 GTK,Windows 上的 Win32 GUI API,MacOS X 上的 Cocoa)。
- GTK 使用主题 API 来伪造平台的外观和感觉(GTK2 上的自定义主题引擎,GTK3 上的基于 CSS 的引擎)。
- Qt 使用样式来伪造平台的外观和感觉。
wxWidgets API is quite ugly from my own experience, because it had too many method just available on one or the other platform making stuff non-portable unless you'd workaround it. Unlike GTK+ and Qt, it also adds its own layer of bugs above the toolkit it uses as a backend. However, it tries hard to have the platform's native look as it uses the native toolkit.
根据我自己的经验,wxWidgets API 非常丑陋,因为它有太多方法只能在一个或另一个平台上使用,除非您解决它,否则这些方法使东西不可移植。与 GTK+ 和 Qt 不同的是,它还在用作后端的工具包之上添加了自己的错误层。但是,由于它使用本机工具包,因此它努力拥有平台的本机外观。
GTK+ 3 still has some rough edges on Windows, which it officially supports since GTK+ 3.6. The GTK+ project delegates to the MSYS2project the distribution of Windows binaries. As you're already using MinGW, that's pretty much the same kind of environment. They have good C++ bindings with GTKmm. However, you may have some work to get the theming right for your version of Windows.
GTK+ 3 在 Windows 上仍然有一些粗糙的地方,它从 GTK+ 3.6 开始正式支持。GTK+ 项目将Windows 二进制文件的分发委托给MSYS2项目。由于您已经在使用 MinGW,这几乎是同一种环境。它们与 GTKmm 具有良好的 C++ 绑定。但是,您可能需要做一些工作才能使主题适合您的 Windows 版本。
Qt is a good choice for cross-platform C++ development with the main target being Windows, tries to mimic the native look and feel of the platform but has its own theming limitations too.
Qt 是跨平台 C++ 开发的不错选择,主要目标是 Windows,它试图模仿平台的本机外观,但也有自己的主题限制。
To sum up, there are only 2 approches:
总结起来,只有两种方法:
- toolkits that provide their own widgets and try to look like the native platform by providing theming (GTK+ and Qt)
- toolkits that use the native widgets but hide their API behind a layer of abstraction (wxWidgets)
- 提供自己的小部件并通过提供主题(GTK+ 和 Qt)来尝试看起来像本机平台的工具包
- 使用本机小部件但将其 API 隐藏在抽象层后面的工具包 (wxWidgets)
Both have their pros and cons.
两者都有其优点和缺点。
回答by VZ.
Implementation details aside, wxWidgets philosophy is, and has always been, to look as natively as possible. We, wxWidgets developers, don't always achieve the goal of looking indistinguishably from the native applications but we always strive to do it and. AFAIK this is not such an important goal for Qt and definitely not for GTK+, so in my (obviously biased) opinion, wxWidgets is your best choice if you are serious about providing the best experience for your users, especially under OS X.
撇开实现细节不谈,wxWidgets 的理念是,而且一直是,尽可能地原生。我们,wxWidgets 开发人员,并不总能达到看起来与原生应用程序没有区别的目标,但我们总是努力做到这一点。AFAIK 这对于 Qt 来说并不是一个重要的目标,对于 GTK+ 绝对不是,所以在我(显然有偏见的)看来,如果您认真地为用户提供最佳体验,尤其是在 OS X 下,wxWidgets 是您的最佳选择。
To answer your question more precisely, everything you list above is implemented using native controls in wxWidgets for Windows (rich text control is not available natively under the other platforms though).
为了更准确地回答您的问题,您上面列出的所有内容都是使用 wxWidgets for Windows 中的本机控件实现的(不过,富文本控件在其他平台下本机不可用)。
回答by Alex V.
IUP - Portable User Interface libraryuses native widgets, C API and Lua bindings.
IUP - 便携式用户界面库使用本机小部件、C API 和 Lua 绑定。
回答by Iton Sandal
i used java for native cross-platform without changing the code, used c/c++ wxwidgets for exclusively cross-platform if you want go to little up performance and standalone executable, used c/c++ winapi for windows and x11 for gnu linux native platform and terminal console, used python for scripting console and platform if you want your software up to date fast, and used assembly for a little simple purely console. And sometimes i combined them all with shared library .dll on windows and .so on gnu linux. And i liked doing for do comparative performance on programming studies with small hardware requirements.
我将 java 用于本机跨平台而不更改代码,如果您想提高性能和独立可执行文件,则将 c/c++ wxwidgets 用于专门的跨平台,将 c/c++ winapi 用于 windows 和 x11 用于 gnu linux 本机平台和终端控制台,如果您希望您的软件快速更新,则使用 python 编写脚本控制台和平台,并使用程序集作为一个简单的纯控制台。有时我将它们与 Windows 上的共享库 .dll 和 gnu linux 上的 .so 结合起来。而且我喜欢在硬件要求较小的编程研究中进行比较性能。