是否可以使用 Visual Studio 创建 C++ GUI?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22823015/
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
Is it possible to create a C++ GUI with Visual Studio?
提问by Zgrkpnr
Can we create C++ GUI applications with Visual Studio or do we need QT like cross platform softwares?
我们可以使用 Visual Studio 创建 C++ GUI 应用程序还是我们需要 QT 之类的跨平台软件?
(By the way, I am assuming if I create a GUI with C++ it would be a cross platform application because as far as I know C++ is a cross platform language)
(顺便说一句,我假设如果我用 C++ 创建一个 GUI,它将是一个跨平台的应用程序,因为据我所知 C++ 是一种跨平台语言)
For some of you maybe this is a very obvious question but I couldn't figure out.
对于你们中的一些人来说,也许这是一个非常明显的问题,但我无法弄清楚。
回答by Reinstate Monica
The C++ language is cross-platform, but its standard libraries don't provide anything specifically for anyGUI development. For that, you need a C++ GUI framework/library. Qt happens to provide just that andit's also cross-platform.
C++ 语言是跨平台的,但它的标准库并没有专门为任何GUI 开发提供任何东西。为此,您需要一个 C++ GUI 框架/库。Qt恰好提供了这一点,而且它也是跨平台的。
So no, without the use of some cross-platform GUI framework, your application not only won't be cross platform, it simply won't have a GUI at all, since C++ standard libraries doen't provide this functionality.
所以不,如果不使用某些跨平台 GUI 框架,您的应用程序不仅不会跨平台,而且根本不会有 GUI,因为 C++ 标准库不提供此功能。
If you use one of the GUI frameworks available only for Windows, like MFC or Windows Runtime, you're not cross-platform.
如果您使用仅适用于 Windows 的 GUI 框架之一,例如 MFC 或 Windows 运行时,则您不是跨平台的。
回答by nobody
C++ has no standard, built-in GUI library. If you want to make cross-platform GUIs you must use an add-on library like C++, GTKmm, wx, etc.
C++ 没有标准的内置 GUI 库。如果你想制作跨平台的 GUI,你必须使用 C++、GTKmm、wx 等附加库。
If you're OK with targeting Windows only, MFCexists and is included with Visual C++.
如果您只针对 Windows,则MFC存在并且包含在 Visual C++ 中。
回答by neminem
There are no GUI libraries built directly into c++. Therefore, any GUI you built using c++ would not be cross-platform. There are a couple GUI libraries that come with Visual Studio - MFC and ATL are both fairly common. Neither are cross-platform, however. That doesn't stop you from using some other GUI framework, of course, if you include it. There are plenty to choose from, including ones that are cross-platform.
没有直接内置到 C++ 中的 GUI 库。因此,您使用 C++ 构建的任何 GUI 都不会是跨平台的。Visual Studio 附带了几个 GUI 库——MFC 和 ATL 都很常见。然而,两者都不是跨平台的。当然,这并不会阻止您使用其他一些 GUI 框架,如果您包含它的话。有很多可供选择,包括跨平台的。
Just because a language is system-independent, doesn't mean people haven't written frameworks for it that aren'tsystem-independent.
仅仅因为一个语言系统无关,并不意味着人们不写它是框架不依赖操作系统的。
回答by π?ντα ?ε?
OK, the point is that qtclaims (and prooves) to be platform independent. It shouldn't matter at least if you compile it on a windows platform using either the MinGw GCC or MSVC toolchain.
好的,关键是qt声称(并证明)是独立于平台的。至少如果您使用 MinGw GCC 或 MSVC 工具链在 Windows 平台上编译它应该无关紧要。
The difference is, if you use Visual Studio's integrated GUI support, you'll end up with their proprietary, non portable CLR/CLI implementations, and the code won't be portable for other platforms.
不同之处在于,如果您使用 Visual Studio 的集成 GUI 支持,您最终会得到他们专有的、不可移植的 CLR/CLI 实现,并且代码将无法移植到其他平台。
回答by markubik
If You want multi platform application, You should concern using Qt. It makes multi platform development easier by providing API for handling both Windows and Linux (and others). You can use Qt in Visual Studio easily. And is really easy to learn. Check official Qt docs for integration tips.
如果您想要多平台应用程序,您应该关注使用 Qt。通过提供用于处理 Windows 和 Linux(以及其他)的 API,它使多平台开发变得更加容易。您可以轻松地在 Visual Studio 中使用 Qt。而且真的很容易学。检查官方 Qt 文档以获取集成提示。