在 Windows 环境中使用 C++ 开发 GUI
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/645425/
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
GUI Development With C++ In A Windows Environment
提问by LogicKills
First off, please understand. I searched this and messed with it for weeks. I have finally given up a solo endeavor and decided to ask this lovely community to help.
首先,请理解。我搜索了这个并弄乱了几个星期。我终于放弃了一个人的努力,决定向这个可爱的社区寻求帮助。
I wanted to write GUI applications for windows. Reason being I wanted to port my favorite command line applications to have an interface. I though 'Hey this shouldn't be this hard'.
我想为 Windows 编写 GUI 应用程序。原因是我想移植我最喜欢的命令行应用程序来拥有一个界面。我想'嘿,这不应该这么难'。
So I Googled for a couple hours and got a good idea of what I needed. I downloaded Qt and installed everything. Next I found a tutorial aimed at using my current IDE (Bloodshed Dev C++) to work with Qt. Everything went to shambles after that.
所以我在谷歌上搜索了几个小时,对我需要的东西有了一个很好的了解。我下载了 Qt 并安装了所有东西。接下来我找到了一个教程,旨在使用我当前的 IDE(Bloodshed Dev C++)来处理 Qt。在那之后,一切都变得一团糟。
I am quite confused what to do now. Some people say my IDE is old and I need to change. Some say I have to configure Windows differently. Someone suggested using Visual Studio C++ (or whatever the Microsoft IDE is).
我现在很困惑该怎么办。有人说我的 IDE 太旧了,我需要改变。有人说我必须以不同的方式配置 Windows。有人建议使用 Visual Studio C++(或任何 Microsoft IDE)。
Here is your where I need your advice and help. What should I do/install/upgrade?
这是你的地方,我需要你的建议和帮助。我应该做什么/安装/升级?
回答by Functastic
As of version 4.5 Qt now comes packaged with the official, cross platform Qt IDE QtCreator. Just download and install Qt 4.5 and you get a full featured (libs, IDE, forms designer, resource editor) development environment for free.
从 4.5 版开始,Qt 现在与官方的、跨平台的 Qt IDE QtCreator 打包在一起。只需下载并安装 Qt 4.5,即可免费获得功能齐全的(库、IDE、表单设计器、资源编辑器)开发环境。
回答by Charlie Martin
Okay, there are two pieces to this.
好的,这有两部分。
The first one is that under Windows, you're going to need a Windows GUI library. You can write to the Windows API in several ways, but the simplestis to use Microsoft's own. That means picking up Visual Studio in some incarnation.
第一个是在 Windows 下,您将需要一个 Windows GUI 库。您可以通过多种方式写入 Windows API,但最简单的是使用 Microsoft 自己的。这意味着在某些化身中选择 Visual Studio。
QT, Wx, and otehrs are all utility libraries built on top of the basic Windows API. They're good for portability to other platforms, but they necessarily add some complexity.
QT、Wx 和 otehrs 都是构建在基本 Windows API 之上的实用程序库。它们有利于向其他平台移植,但它们必然会增加一些复杂性。
For C++, you need a compiler. Again, for Windows, the simplest thing is to use Visual Studio, but there are other compilers available. The most common free one is going to be the GNU compilers. The easy way to get those is with Cygwin, but that is a UNIX-like environment.
对于 C++,您需要一个编译器。同样,对于 Windows,最简单的方法是使用 Visual Studio,但还有其他可用的编译器。最常见的免费编译器将是 GNU 编译器。获得这些的简单方法是使用 Cygwin,但这是一个类 UNIX 环境。
I think the conclusion is that for a beginner, you're best off with Visual Studio.
我认为结论是,对于初学者来说,最好使用 Visual Studio。
Once you get it, there are many tutorial around on the web and at Microsoft to learn to use it.
一旦你得到它,网上和微软有很多教程来学习使用它。
回答by Dani van der Meer
You have a lot of options and you could use a lot of tools as described by Charlie Martin. I think that if you want the easiest path, you should use wxDev-C++which is Dev-C++ bundled with the wxWidgets GUI library. After you install it, you can directly develop GUI applications without need for extra configuration. Maybe Dev-c++ is an old IDE, but you already use it and you know it. And wxWidgets is a solid GUI library.
你有很多选择,你可以使用很多工具,正如查理马丁所描述的那样。我认为如果你想要最简单的路径,你应该使用wxDev-C++,它是与 wxWidgets GUI 库捆绑在一起的 Dev-C++。安装后,无需额外配置即可直接开发GUI应用程序。也许 Dev-c++ 是一个旧的 IDE,但你已经使用过它并且你知道它。wxWidgets 是一个可靠的 GUI 库。
回答by Rob
Visual Studio 2008 + WTLwould be a great combination if you're not worried about cross-platform support. Qt looks great, but for a simple app it might be overkill - distributing a Qt app means shipping a bunch of DLLs for example, whereas you have fewer dependencies with WTL.
如果您不担心跨平台支持,Visual Studio 2008 + WTL将是一个很好的组合。Qt 看起来很棒,但对于一个简单的应用程序来说,它可能有点矫枉过正——例如,分发一个 Qt 应用程序意味着传送一堆 DLL,而您对 WTL 的依赖较少。
Just my 2c. I don't want to start any flame wars here. :)
只是我的2c。我不想在这里开始任何火焰War。:)
回答by Steve Rowe
While possible to use your current IDE and a toolkit like Qt, if you are looking for the path of least resistence, you should go with Visual Studio. You'll find the best documentation and the most support going that route. Check out the Express Editionwhich is free (as in beer). Then go grab a copy of a good book on the subject like Charles Petzold's Programming Windows. You should be all set.
虽然可以使用您当前的 IDE 和 Qt 等工具包,但如果您正在寻找阻力最小的路径,则应该使用 Visual Studio。您会在这条路线上找到最好的文档和最多的支持。查看免费的Express Edition(如啤酒)。然后去拿一本关于这个主题的好书,比如 Charles Petzold 的Windows 编程。你应该准备好了。
回答by Chris
I use Ultimate++ http://ultimatepp.org/for cross platform C++ GUI development. It also has a complete library of utilities for networking, databases, etc and a really good IDE. It's BSD licensed, so no issues doing what you want with it. It has really good community support as well.
我使用Ultimate++ http://ultimatepp.org/进行跨平台 C++ GUI 开发。它还具有用于网络、数据库等的完整实用程序库和一个非常好的 IDE。它是 BSD 许可的,所以用它做你想做的事情没有问题。它也有非常好的社区支持。
回答by Chris
Dev C++ is no longer under active development (and is a bit naff anyway). If you want an open source IDE which supports Windows GUI development, try Code::Blocks.
Dev C++ 不再处于积极的开发阶段(无论如何都有些无趣)。如果您想要一个支持 Windows GUI 开发的开源 IDE,请尝试Code::Blocks。
回答by NTDLS
First off, Dev-C++ is no longer under development and seems to have been abandoned with lots of bugs. Second, IFyou want to stick with windows API, check out my little Dialog Templateproject.
首先,Dev-C++ 不再处于开发阶段,似乎已经被大量 bug 抛弃了。其次,如果您想坚持使用 Windows API,请查看我的小对话框模板项目。
I just added project files for Visual Studio 2008, Code::Blocks & Dev-C++ just to get you moving. Let me know if you need anything else, as I'd be happy to help you along.
我刚刚为 Visual Studio 2008、Code::Blocks 和 Dev-C++ 添加了项目文件,只是为了让您动起来。如果您需要其他任何东西,请告诉我,因为我很乐意为您提供帮助。
回答by NTDLS
The following assumes that you are targetting a Windows only platform (if you are looking cross-OS - then lots of the other posts cover various options).
以下假设您的目标是仅限 Windows 的平台(如果您正在寻找跨操作系统 - 那么许多其他帖子涵盖了各种选项)。
You may be quite fortunate in that you already have an application that can be run from the command line. It is entirely possible to work in one of the .Net languages and access your existing application. Any .Net language (C#, VB.Net, managed C++) can be used to very quickly construct a UI and bind UI components and events and then have that call out to your existing application - passing down the necessary command line arguments.
您可能很幸运,因为您已经拥有一个可以从命令行运行的应用程序。完全有可能使用一种 .Net 语言并访问您现有的应用程序。任何 .Net 语言(C#、VB.Net、托管 C++)都可用于非常快速地构建 UI 并绑定 UI 组件和事件,然后调用现有应用程序 - 传递必要的命令行参数。
Another option: Managed C++ actually allows you to mix managed (.Net code) and unManaged code (standards compliant C++ - i.e. - your existing applications) in the same projects (even the same files for lots of code). This allows you access to many modern IDE features and the .Net library for anything net new that you want to add. You simply play a bit with some project settings and "it just works" (well - there might be some learning things but it is quite easy).
另一种选择:托管 C++ 实际上允许您在同一项目(甚至是许多代码的相同文件)中混合托管(.Net 代码)和非托管代码(符合标准的 C++ - 即 - 您现有的应用程序)。这允许您访问许多现代 IDE 功能和 .Net 库,用于您想要添加的任何网络新功能。您只需玩一些项目设置,然后“它就可以工作了”(好吧 - 可能有一些学习的东西,但很容易)。
While I have a full version of Visual Studio - I believe that the free "Express" versions (http://www.microsoft.com/express/product/) are quite capable for many of these tasks.
虽然我有完整版的 Visual Studio,但我相信免费的“Express”版本 ( http://www.microsoft.com/express/product/) 能够胜任其中的许多任务。