Possible Duplicate:
Gui toolkits, which should I use?可能重复:Gui工具包,我应该使用哪个?
I've got a fair bit of C/C++ experience - mostly for writing console application for Windows/Linux, and also a fair bit of C# experience - generally for writing WinForms applications etc.
我有相当多的C / C ++经验 - 主要是为Windows / Linux编写控制台应用程序,还有一些C#经验 - 通常用于编写WinForms应用程序等。
I'm extremely impressed with with ease at which I can create a window in .net, for example something as simple as
我非常感到非常印象深刻,我可以在.net中创建一个窗口,例如简单的东西
Form form = new Form();
form.ShowDialog();
is enough to get a blank form up on the screen. In fact,
足以在屏幕上显示空白表格。事实上,
new Form().ShowDialog();
is technically enough as long as we don't mind losing reference to the form after it's closed.
只要我们不介意在表格关闭后失去对表格的引用,这在技术上就足够了。
I've tried writing some windows-based GUI stuff in C++ using windows.h
, but not only does the learning curve seem a little steep but also the syntax is extremely verbose. Creating a simple window like the above mentioned single line .net implementation can easily exceed 2 dozen lines using windows.h
.
我尝试使用windows.h在C ++中编写一些基于Windows的GUI东西,但不仅学习曲线看起来有点陡峭,而且语法也非常冗长。创建一个像上面提到的单行.net实现这样的简单窗口,使用windows.h可以轻松超过24行。
But not only that, if I were to port the application over to Linux/Max (something which I can pretty much never do with .net, with the exception of hacks like mono etc), then I would need to rewrite 95% of the GUI code.
但不仅如此,如果我将应用程序移植到Linux / Max(我几乎不会使用.net,除了单声道等黑客之外),那么我需要重写95%的GUI代码。
I'm assuming this is where frameworks come in, for example QT etc... (I don't really know much about gui frameworks, I'm afraid).
我假设这是框架进入的地方,例如QT等......(我真的不太了解gui框架,我很害怕)。
What GUI frameworks do you recommend? which are the most powerful and which are the easiest to use? How do you generally tackle the task of coding your GUI in C/C++?
您推荐哪些GUI框架?哪个是最强大的,哪个最容易使用?您如何解决在C / C ++中编写GUI的任务?
2 个解决方案
#1
2
Qt, hands down.
Qt,放下手。
it's the most complete, most mature, fastest framework available. and on top of it, it's seriously multiplaftorm and your choice of commercially friendly open source or paid support.
它是最完整,最成熟,最快的框架。在它的基础上,它是严重的多平台和您选择的商业友好的开源或付费支持。
#2
5
The closer to the metal (so to speak) that you are programming, the more difficult things get. WinForms (provided by the .NET Framework) is a pretty outstanding abstraction over the Win32 API, considering the complexity you've already seen that it involves for the even the simplest of tasks, like getting a window to appear on the screen. All of that is still happening in the background, of course (registering a window class, creating the window, etc.), you just don't have to write the code yourself.
你正在编程越接近金属(可以这么说),就会越难获得。 WinForms(由.NET Framework提供)是一个非常出色的Win32 API抽象,考虑到你已经看到的复杂性,即使是最简单的任务,例如让窗口出现在屏幕上。所有这些仍然在后台发生,当然(注册窗口类,创建窗口等),你不必自己编写代码。
It's interesting that you write off Mono as a "hack", but would consider a library like Qt. I'm really not sure on what basis you make the distinction. The Mono library is widely regarded as excellent when it comes to WinForms support. The biggest detractors are the same as Microsoft's own CLR implementation, namely that it doesn't produce truly native code, which is more irrelevant to performance in the majority of situations than one might think. Beyond that, some complain that Mono applications don't conform fully to the platform's UI guidelines (that is, they don't look and behave exactly like a native application would), but I have a similar complaint about applications written using Qt.
有趣的是你把Mono注销为“黑客”,但会考虑像Qt这样的库。我真的不确定你在什么基础上做出区分。在WinForms支持方面,Mono库被广泛认为是优秀的。最大的批评者与微软自己的CLR实现相同,即它不会产生真正的本机代码,这在大多数情况下与性能无关。除此之外,一些人抱怨Mono应用程序不完全符合平台的UI指南(也就是说,它们的外观和行为与本机应用程序完全不同),但我对使用Qt编写的应用程序有类似的抱怨。
It seems like literally everyone recommends using Qt if you want to do GUI work in C++. As I mentioned above, it happens not to be my favorite library because I'm a stickler for using fully native controls and widgets provided by the platform you're currently running on. I understand that Qt has gotten a little better at this recently, but I still don't think it's up to my standards. If you're more flexible than I am (and I'll warn you that the average Mac user is not any more flexible than I am), and true platform independence is a big concern to you, it's probably the one you should opt for. Many people praise it for its design elegance and convenience, although I seriously doubt that even it offers the same simplicity as the .NET Framework's implementation.
如果你想在C ++中进行GUI工作,似乎每个人都建议使用Qt。正如我上面提到的,它碰巧不是我最喜欢的库,因为我是使用您当前运行的平台提供的完全本机控件和小部件的坚持者。我知道Qt最近在这方面有所改善,但我仍然认为这不符合我的标准。如果你比我更灵活(我会警告你,普通的Mac用户并不比我更灵活),真正的平*立性对你来说是一个很大的问题,它可能是你应该选择的那个。许多人赞扬它的设计优雅和便利,虽然我严重怀疑它甚至提供与.NET Framework实现相同的简单性。
If sheer simplicity and terseness of code is as important as the beginning of your question makes it sound, I highly recommend sticking with C# and WinForms. Things get harder as you start to remove layers of abstraction, and if you don't need the extra levels of control that doing so affords you, there's hardly any justification for making more work for yourself. Mono's Forms implementation is a perfectly viable solution for cross-platform applications, assuming your needs are relatively modest.
如果简单和简洁的代码与问题的开头一样重要,那么我强烈建议坚持使用C#和WinForms。当你开始删除抽象层时,事情变得越来越困难,如果你不需要额外的控制水平,这样就可以为你自己做更多的工作。 Mono的Forms实现是跨平台应用程序的完美可行解决方案,假设您的需求相对适中。
Beyond that, if you want to create a truly cross-platform application in C++ the right way, I recommend that you strictly separate your data layer code from your UI layer, and then write the UI using the tools provided by each platform you want to support. In Windows, your options are relatively open: .NET WinForms is a solid choice, native Win32 is a somewhat painful though merited option, and a handful of other libraries like MFC and WxWidgets can help to ease the pain of fully native programming (though not nearly as well as WinForms does). On the Mac, the only real option is Xcode, Interface Builder, and Objective-C, targeting the Cocoa framework. Linux/Unix-based systems are hardly my forte, but I'm given to understand that Qt is about as native a library as you can get. This sounds like more work than I think it is—a well-designed library should handle 80% of the work, leaving only around 20% that you have to do in implementing the UI. Beyond using truly native controls and widgets, I think the other big advantage afforded by this approach is flexibility. Notice how Microsoft Word looks very different (despite some superficial similarities) on Windows than it does on the Mac. And iTunes has become almost a paragon of excellent UI design on the Mac platform, but sticks out like a sore thumb on Windows. On the other hand, if you rolled out something like Windows Media Player on the Mac (and yes, it's been tried by Microsoft themselves, though without much success), Mac users will dismiss it as a complete abomination and probably be somewhat offended that you even tried. Not so good for the truly cross-platform-minded developer. All of that to say, if your app is anything but the simplest of utilities, you'll probably find that an entirely different interface is justified (and even expected) on each platform that you want to support.
No matter how great Qt may be, you're not going to get that with it.
除此之外,如果您想以正确的方式在C ++中创建真正的跨平台应用程序,我建议您严格地将数据层代码与UI层分开,然后使用您希望的每个平台提供的工具编写UI。支持。在Windows中,你的选项是相对开放的:.NET WinForms是一个不错的选择,本机Win32虽然是一个有点痛苦的选项,但是MFC和WxWidgets等少数其他库可以帮助减轻完全本机编程的痛苦(尽管不是几乎和WinForms一样)。在Mac上,唯一真正的选择是Xcode,Interface Builder和Objective-C,目标是Cocoa框架。基于Linux / Unix的系统不是我的强项,但是我明白了Qt就像你可以获得的本地库一样。这听起来比我认为的更多 - 一个设计良好的库应该可以处理80%的工作,只留下大约20%的实现UI所需要做的事情。除了使用真正的原生控件和小部件之外,我认为这种方法提供的另一大优势是灵活性。请注意,Windows上的Microsoft Word与Mac上的相似之处(尽管存在一些表面上的相似之处)。 iTunes已经成为Mac平台上优秀的UI设计的典范,但在Windows上却像一个痛苦的拇指一样突出。另一方面,如果你在Mac上推出了类似Windows Media Player的东西(是的,它已被微软自己试过,虽然没有太大的成功),Mac用户会认为它是一个完全可憎的东西,可能有点冒犯你甚至尝试过。对于真正跨平台的开发人员来说,这不太好。所有这些,如果您的应用程序不是最简单的实用程序,您可能会发现在您想要支持的每个平台上,完全不同的界面是合理的(甚至是预期的)。无论Qt多么伟大,你都无法用它来获得它。
#1
2
Qt, hands down.
Qt,放下手。
it's the most complete, most mature, fastest framework available. and on top of it, it's seriously multiplaftorm and your choice of commercially friendly open source or paid support.
它是最完整,最成熟,最快的框架。在它的基础上,它是严重的多平台和您选择的商业友好的开源或付费支持。
#2
5
The closer to the metal (so to speak) that you are programming, the more difficult things get. WinForms (provided by the .NET Framework) is a pretty outstanding abstraction over the Win32 API, considering the complexity you've already seen that it involves for the even the simplest of tasks, like getting a window to appear on the screen. All of that is still happening in the background, of course (registering a window class, creating the window, etc.), you just don't have to write the code yourself.
你正在编程越接近金属(可以这么说),就会越难获得。 WinForms(由.NET Framework提供)是一个非常出色的Win32 API抽象,考虑到你已经看到的复杂性,即使是最简单的任务,例如让窗口出现在屏幕上。所有这些仍然在后台发生,当然(注册窗口类,创建窗口等),你不必自己编写代码。
It's interesting that you write off Mono as a "hack", but would consider a library like Qt. I'm really not sure on what basis you make the distinction. The Mono library is widely regarded as excellent when it comes to WinForms support. The biggest detractors are the same as Microsoft's own CLR implementation, namely that it doesn't produce truly native code, which is more irrelevant to performance in the majority of situations than one might think. Beyond that, some complain that Mono applications don't conform fully to the platform's UI guidelines (that is, they don't look and behave exactly like a native application would), but I have a similar complaint about applications written using Qt.
有趣的是你把Mono注销为“黑客”,但会考虑像Qt这样的库。我真的不确定你在什么基础上做出区分。在WinForms支持方面,Mono库被广泛认为是优秀的。最大的批评者与微软自己的CLR实现相同,即它不会产生真正的本机代码,这在大多数情况下与性能无关。除此之外,一些人抱怨Mono应用程序不完全符合平台的UI指南(也就是说,它们的外观和行为与本机应用程序完全不同),但我对使用Qt编写的应用程序有类似的抱怨。
It seems like literally everyone recommends using Qt if you want to do GUI work in C++. As I mentioned above, it happens not to be my favorite library because I'm a stickler for using fully native controls and widgets provided by the platform you're currently running on. I understand that Qt has gotten a little better at this recently, but I still don't think it's up to my standards. If you're more flexible than I am (and I'll warn you that the average Mac user is not any more flexible than I am), and true platform independence is a big concern to you, it's probably the one you should opt for. Many people praise it for its design elegance and convenience, although I seriously doubt that even it offers the same simplicity as the .NET Framework's implementation.
如果你想在C ++中进行GUI工作,似乎每个人都建议使用Qt。正如我上面提到的,它碰巧不是我最喜欢的库,因为我是使用您当前运行的平台提供的完全本机控件和小部件的坚持者。我知道Qt最近在这方面有所改善,但我仍然认为这不符合我的标准。如果你比我更灵活(我会警告你,普通的Mac用户并不比我更灵活),真正的平*立性对你来说是一个很大的问题,它可能是你应该选择的那个。许多人赞扬它的设计优雅和便利,虽然我严重怀疑它甚至提供与.NET Framework实现相同的简单性。
If sheer simplicity and terseness of code is as important as the beginning of your question makes it sound, I highly recommend sticking with C# and WinForms. Things get harder as you start to remove layers of abstraction, and if you don't need the extra levels of control that doing so affords you, there's hardly any justification for making more work for yourself. Mono's Forms implementation is a perfectly viable solution for cross-platform applications, assuming your needs are relatively modest.
如果简单和简洁的代码与问题的开头一样重要,那么我强烈建议坚持使用C#和WinForms。当你开始删除抽象层时,事情变得越来越困难,如果你不需要额外的控制水平,这样就可以为你自己做更多的工作。 Mono的Forms实现是跨平台应用程序的完美可行解决方案,假设您的需求相对适中。
Beyond that, if you want to create a truly cross-platform application in C++ the right way, I recommend that you strictly separate your data layer code from your UI layer, and then write the UI using the tools provided by each platform you want to support. In Windows, your options are relatively open: .NET WinForms is a solid choice, native Win32 is a somewhat painful though merited option, and a handful of other libraries like MFC and WxWidgets can help to ease the pain of fully native programming (though not nearly as well as WinForms does). On the Mac, the only real option is Xcode, Interface Builder, and Objective-C, targeting the Cocoa framework. Linux/Unix-based systems are hardly my forte, but I'm given to understand that Qt is about as native a library as you can get. This sounds like more work than I think it is—a well-designed library should handle 80% of the work, leaving only around 20% that you have to do in implementing the UI. Beyond using truly native controls and widgets, I think the other big advantage afforded by this approach is flexibility. Notice how Microsoft Word looks very different (despite some superficial similarities) on Windows than it does on the Mac. And iTunes has become almost a paragon of excellent UI design on the Mac platform, but sticks out like a sore thumb on Windows. On the other hand, if you rolled out something like Windows Media Player on the Mac (and yes, it's been tried by Microsoft themselves, though without much success), Mac users will dismiss it as a complete abomination and probably be somewhat offended that you even tried. Not so good for the truly cross-platform-minded developer. All of that to say, if your app is anything but the simplest of utilities, you'll probably find that an entirely different interface is justified (and even expected) on each platform that you want to support.
No matter how great Qt may be, you're not going to get that with it.
除此之外,如果您想以正确的方式在C ++中创建真正的跨平台应用程序,我建议您严格地将数据层代码与UI层分开,然后使用您希望的每个平台提供的工具编写UI。支持。在Windows中,你的选项是相对开放的:.NET WinForms是一个不错的选择,本机Win32虽然是一个有点痛苦的选项,但是MFC和WxWidgets等少数其他库可以帮助减轻完全本机编程的痛苦(尽管不是几乎和WinForms一样)。在Mac上,唯一真正的选择是Xcode,Interface Builder和Objective-C,目标是Cocoa框架。基于Linux / Unix的系统不是我的强项,但是我明白了Qt就像你可以获得的本地库一样。这听起来比我认为的更多 - 一个设计良好的库应该可以处理80%的工作,只留下大约20%的实现UI所需要做的事情。除了使用真正的原生控件和小部件之外,我认为这种方法提供的另一大优势是灵活性。请注意,Windows上的Microsoft Word与Mac上的相似之处(尽管存在一些表面上的相似之处)。 iTunes已经成为Mac平台上优秀的UI设计的典范,但在Windows上却像一个痛苦的拇指一样突出。另一方面,如果你在Mac上推出了类似Windows Media Player的东西(是的,它已被微软自己试过,虽然没有太大的成功),Mac用户会认为它是一个完全可憎的东西,可能有点冒犯你甚至尝试过。对于真正跨平台的开发人员来说,这不太好。所有这些,如果您的应用程序不是最简单的实用程序,您可能会发现在您想要支持的每个平台上,完全不同的界面是合理的(甚至是预期的)。无论Qt多么伟大,你都无法用它来获得它。