简体   繁体   English

开始使用GUI C ++编程的最佳方法是什么?

[英]What is the best way to get started in GUI C++ programming?

So, I learned C++ (fundamentals) and I want to write software, however I have stumbled upon a problem where I don't know where to get started. 所以,我学习了C ++(基础知识)并且我想编写软件,但是我偶然发现了一个我不知道从哪里开始的问题。 It seems like learning C++ was the easiest part by far when it comes to understanding the libraries for the GUI construction the concept I yet don't fully comprehend. 到目前为止,在理解用于GUI构建的库时,学习C ++似乎是最简单的部分,这个概念我还没有完全理解。 I searched a lot and couldn't even decide been a new guy on MFC, Win32 or Qt. 我搜索了很多,甚至不能决定是MFC,Win32或Qt上的新人。

Qt C++ GUI seems like a fun and easy to use software with the definitions of classes available right there quickly. Qt C ++ GUI看起来像一个有趣且易于使用的软件,可快速在那里提供类的定义。

With Visual's MFC I am seeing a lot of code upfront on the pre made project file and a lot of description of classes, however getting definitions is a bit slower as I have to go to the internet. 使用Visual的MFC,我在预制的项目文件和许多类的描述中预先看到了很多代码,但是由于我必须上网,因此获取定义的速度要慢一些。

Win32 is apparently written in C and is not updated much? Win32显然是用C编写的,并没有更新太多?

A lot of people recommend Java and C# as well, but I am not interested in learning a new language when I don't have C++ set in stone and practiced with enough yet. 很多人也推荐使用Java和C#,但是当我没有C ++并且还有足够的实践时,我对学习一门新语言不感兴趣。

Not sure how to go about this. 不知道该怎么做。

Go with Qt if you envision porting your program to platforms other than Windows and/or your actual UI needs are relatively straightforward. 如果您设想将程序移植到Windows以外的平台和/或您的实际UI需求相对简单,请使用Qt。 But Qt, being "fun," abstracts you away from the Windows API, so if you find yourself needing to access features of that API not offered by Qt, then you'll be up the creek. 但Qt,“有趣”,将您从Windows API中抽象出来,所以如果您发现自己需要访问Qt不提供的API的功能,那么您将成为小溪。 So go with MFC if you're staying on Windows and you're building an application whose complexity or Windows-specific features may require more direct access to the Windows API. 因此,如果您使用的是MFC,那么您正在构建一个应用程序,其复杂性或Windows特定功能可能需要更直接地访问Windows API。 MFC provides a thin abstraction layer over that API; MFC在该API上提供了一个精简的抽象层; its concepts map more or less one-to-one with the API's concepts. 它的概念或多或少地与API的概念一一对应。

What kind of GUI do you want? 你想要什么样的GUI? Any framework should be able to do any kind of GUI, but some are optimized for certain work: 任何框架都应该能够执行任何类型的GUI,但有些框架针对某些工作进行了优化:

  • MFC is optimized for making applications that edit documents, like MS Office programs Word, Excel, Powerpoint. MFC针对编辑文档的应用程序进行了优化,例如MS Office程序Word,Excel,Powerpoint。
  • wxWidgets and Qt (and .NET WinForms and WPF) are optimized for any sort of app that primarily uses widgets (textboxes, buttons, menus). wxWidgets和Qt(以及.NET WinForms和WPF)针对主要使用小部件(文本框,按钮,菜单)的任何类型的应用程序进行了优化。
  • SDL is optimized if you want to draw stuff, like graphs or vector artwork. 如果您想绘制图形或矢量图形等内容,SDL会进行优化。

I wouldn't recommend that you use MFC since it isn't a good fit for most applications, and also doesn't use modern C++ design, it's loaded with workarounds needed for stuff that was broken in early versions of Visual C++ and now can't shake those workarounds because of backward compatibility. 我不建议您使用MFC,因为它不适合大多数应用程序,也不使用现代C ++设计,它加载了早期版本的Visual C ++中破坏的东西所需的变通方法,现在可以由于向后兼容性,请动摇这些变通方法。

The Win32 API is actually really useful to know regardless of what kind of application you want to make, because it defines the rules for how the UI interfaces to the rest of the system. 无论您想要制作何种类型的应用程序,Win32 API实际上都非常有用,因为它定义了UI如何与系统其余部分接口的规则。 Yes, it's written in C, but this is to make it usable from any programming language, not because it's an obsolete design. 是的,它是用C语言编写的,但这是为了使它可以从任何编程语言中使用,而不是因为它是一个过时的设计。 Win32 API is highly object-oriented and uses polymorphism extensively. Win32 API是高度面向对象的,并且广泛使用多态。

Few things you need to be aware of: 您需要注意的几件事情:

If one day you want to sell a program written using Qt you might need to purchase a license. 如果有一天您想要销售使用Qt编写的程序,您可能需要购买许可证。

If you feel like GUI applications/ GUI programming is what you want to do in general, for windows platform you better learn WinForms or even better WPF (with C# of course). 如果您觉得GUI应用程序/ GUI编程通常是您想要做的,对于Windows平台,您最好学习WinForms甚至更好的WPF(当然还有C#)。

If you just want to quickly put up simple GUIs for your C++ programs for learning purposes, and you don't care much about learning the frameworks and licensing issues, just go with Qt or wxWidgets. 如果您只是想为学习目的快速为您的C ++程序设置简单的GUI,并且您不太关心学习框架和许可问题,那么请使用Q​​t或wxWidgets。

MFC is outdated. MFC已经过时了。 If sticking with C++ on Windows, I recommend you to lean C++ CLI. 如果在Windows上坚持使用C ++,我建议您使用C ++ CLI。 However I suggest you to learn c# directly since c# is the mainstream language in .Net world. 但是我建议你直接学习c#,因为c#是.Net世界的主流语言。 For GUI, the windows world is now dominated by WPF. 对于GUI,Windows世界现在由WPF主导。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM